diff --git a/compiler/rustc_mir_transform/src/const_prop_lint.rs b/compiler/rustc_mir_transform/src/const_prop_lint.rs index f8e6905282c59..6212155a8fe95 100644 --- a/compiler/rustc_mir_transform/src/const_prop_lint.rs +++ b/compiler/rustc_mir_transform/src/const_prop_lint.rs @@ -32,11 +32,6 @@ impl<'tcx> MirLint<'tcx> for ConstPropLint { return; } - // will be evaluated by miri and produce its errors there - if body.source.promoted.is_some() { - return; - } - let def_id = body.source.def_id().expect_local(); let def_kind = tcx.def_kind(def_id); let is_fn_like = def_kind.is_fn_like(); diff --git a/src/tools/miri/tests/pass/overflow_checks_off.rs b/src/tools/miri/tests/pass/overflow_checks_off.rs index 79aa510ef97fe..7b9d4f8fff5d5 100644 --- a/src/tools/miri/tests/pass/overflow_checks_off.rs +++ b/src/tools/miri/tests/pass/overflow_checks_off.rs @@ -1,12 +1,17 @@ //@compile-flags: -C overflow-checks=off // Check that we correctly implement the intended behavior of these operators -// when they are not being overflow-checked. +// when they are not being overflow-checked at runtime. // FIXME: if we call the functions in `std::ops`, we still get the panics. // Miri does not implement the codegen-time hack that backs `#[rustc_inherit_overflow_checks]`. // use std::ops::*; + +// Disable _compile-time_ overflow linting +// so that we can test runtime overflow checks + #![allow(arithmetic_overflow)] + fn main() { assert_eq!(-{ -0x80i8 }, -0x80); diff --git a/tests/ui/associated-consts/defaults-cyclic-fail.stderr b/tests/ui/associated-consts/defaults-cyclic-fail.stderr index 9cee03041fe6d..31974d955611f 100644 --- a/tests/ui/associated-consts/defaults-cyclic-fail.stderr +++ b/tests/ui/associated-consts/defaults-cyclic-fail.stderr @@ -20,7 +20,7 @@ note: ...which requires const-evaluating + checking `Tr::B`... LL | const B: u8 = Self::A; | ^^^^^^^ = note: ...which again requires simplifying constant for the type system `Tr::A`, completing the cycle -note: cycle used when const-evaluating + checking `main::promoted[1]` +note: cycle used when optimizing promoted MIR for `main` --> $DIR/defaults-cyclic-fail.rs:16:16 | LL | assert_eq!(<() as Tr>::A, 0); diff --git a/tests/ui/associated-consts/defaults-not-assumed-fail.stderr b/tests/ui/associated-consts/defaults-not-assumed-fail.stderr index 091a50f9463b9..4b53603cfe851 100644 --- a/tests/ui/associated-consts/defaults-not-assumed-fail.stderr +++ b/tests/ui/associated-consts/defaults-not-assumed-fail.stderr @@ -10,6 +10,14 @@ note: erroneous constant encountered LL | assert_eq!(<() as Tr>::B, 0); // causes the error above | ^^^^^^^^^^^^^ +note: erroneous constant encountered + --> $DIR/defaults-not-assumed-fail.rs:33:16 + | +LL | assert_eq!(<() as Tr>::B, 0); // causes the error above + | ^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + note: erroneous constant encountered --> $DIR/defaults-not-assumed-fail.rs:33:5 | diff --git a/tests/ui/consts/const-err2.noopt.stderr b/tests/ui/consts/const-err2.noopt.stderr deleted file mode 100644 index 8b1688c4a8989..0000000000000 --- a/tests/ui/consts/const-err2.noopt.stderr +++ /dev/null @@ -1,48 +0,0 @@ -error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:19:13 - | -LL | let a = -i8::MIN; - | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow - | - = note: `#[deny(arithmetic_overflow)]` on by default - -error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:21:18 - | -LL | let a_i128 = -i128::MIN; - | ^^^^^^^^^^ attempt to negate `i128::MIN`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:23:13 - | -LL | let b = 200u8 + 200u8 + 200u8; - | ^^^^^^^^^^^^^ attempt to compute `200_u8 + 200_u8`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:25:18 - | -LL | let b_i128 = i128::MIN - i128::MAX; - | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN - i128::MAX`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:27:13 - | -LL | let c = 200u8 * 4; - | ^^^^^^^^^ attempt to compute `200_u8 * 4_u8`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:29:13 - | -LL | let d = 42u8 - (42u8 + 1); - | ^^^^^^^^^^^^^^^^^ attempt to compute `42_u8 - 43_u8`, which would overflow - -error: this operation will panic at runtime - --> $DIR/const-err2.rs:31:14 - | -LL | let _e = [5u8][1]; - | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 - | - = note: `#[deny(unconditional_panic)]` on by default - -error: aborting due to 7 previous errors - diff --git a/tests/ui/consts/const-err2.opt.stderr b/tests/ui/consts/const-err2.opt.stderr deleted file mode 100644 index 8b1688c4a8989..0000000000000 --- a/tests/ui/consts/const-err2.opt.stderr +++ /dev/null @@ -1,48 +0,0 @@ -error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:19:13 - | -LL | let a = -i8::MIN; - | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow - | - = note: `#[deny(arithmetic_overflow)]` on by default - -error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:21:18 - | -LL | let a_i128 = -i128::MIN; - | ^^^^^^^^^^ attempt to negate `i128::MIN`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:23:13 - | -LL | let b = 200u8 + 200u8 + 200u8; - | ^^^^^^^^^^^^^ attempt to compute `200_u8 + 200_u8`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:25:18 - | -LL | let b_i128 = i128::MIN - i128::MAX; - | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN - i128::MAX`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:27:13 - | -LL | let c = 200u8 * 4; - | ^^^^^^^^^ attempt to compute `200_u8 * 4_u8`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:29:13 - | -LL | let d = 42u8 - (42u8 + 1); - | ^^^^^^^^^^^^^^^^^ attempt to compute `42_u8 - 43_u8`, which would overflow - -error: this operation will panic at runtime - --> $DIR/const-err2.rs:31:14 - | -LL | let _e = [5u8][1]; - | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 - | - = note: `#[deny(unconditional_panic)]` on by default - -error: aborting due to 7 previous errors - diff --git a/tests/ui/consts/const-err2.opt_with_overflow_checks.stderr b/tests/ui/consts/const-err2.opt_with_overflow_checks.stderr deleted file mode 100644 index 8b1688c4a8989..0000000000000 --- a/tests/ui/consts/const-err2.opt_with_overflow_checks.stderr +++ /dev/null @@ -1,48 +0,0 @@ -error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:19:13 - | -LL | let a = -i8::MIN; - | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow - | - = note: `#[deny(arithmetic_overflow)]` on by default - -error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:21:18 - | -LL | let a_i128 = -i128::MIN; - | ^^^^^^^^^^ attempt to negate `i128::MIN`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:23:13 - | -LL | let b = 200u8 + 200u8 + 200u8; - | ^^^^^^^^^^^^^ attempt to compute `200_u8 + 200_u8`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:25:18 - | -LL | let b_i128 = i128::MIN - i128::MAX; - | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN - i128::MAX`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:27:13 - | -LL | let c = 200u8 * 4; - | ^^^^^^^^^ attempt to compute `200_u8 * 4_u8`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:29:13 - | -LL | let d = 42u8 - (42u8 + 1); - | ^^^^^^^^^^^^^^^^^ attempt to compute `42_u8 - 43_u8`, which would overflow - -error: this operation will panic at runtime - --> $DIR/const-err2.rs:31:14 - | -LL | let _e = [5u8][1]; - | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 - | - = note: `#[deny(unconditional_panic)]` on by default - -error: aborting due to 7 previous errors - diff --git a/tests/ui/consts/const-err2.rs b/tests/ui/consts/const-err2.rs deleted file mode 100644 index 67c85d35401d5..0000000000000 --- a/tests/ui/consts/const-err2.rs +++ /dev/null @@ -1,39 +0,0 @@ -// needed because negating int::MIN will behave differently between -// optimized compilation and unoptimized compilation and thus would -// lead to different lints being emitted - -//@ revisions: noopt opt opt_with_overflow_checks -//@[noopt]compile-flags: -C opt-level=0 -//@[opt]compile-flags: -O -//@[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O - -//@ build-fail - -#![feature(rustc_attrs)] - -fn black_box(_: T) { - unimplemented!() -} - -fn main() { - let a = -i8::MIN; - //~^ ERROR arithmetic operation will overflow - let a_i128 = -i128::MIN; - //~^ ERROR arithmetic operation will overflow - let b = 200u8 + 200u8 + 200u8; - //~^ ERROR arithmetic operation will overflow - let b_i128 = i128::MIN - i128::MAX; - //~^ ERROR arithmetic operation will overflow - let c = 200u8 * 4; - //~^ ERROR arithmetic operation will overflow - let d = 42u8 - (42u8 + 1); - //~^ ERROR arithmetic operation will overflow - let _e = [5u8][1]; - //~^ ERROR operation will panic - black_box(a); - black_box(a_i128); - black_box(b); - black_box(b_i128); - black_box(c); - black_box(d); -} diff --git a/tests/ui/consts/const-eval/issue-44578.stderr b/tests/ui/consts/const-eval/issue-44578.stderr index 6aabe53011c96..7d5cf86d3965d 100644 --- a/tests/ui/consts/const-eval/issue-44578.stderr +++ b/tests/ui/consts/const-eval/issue-44578.stderr @@ -10,6 +10,14 @@ note: erroneous constant encountered LL | println!("{}", as Foo>::AMT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: erroneous constant encountered + --> $DIR/issue-44578.rs:25:20 + | +LL | println!("{}", as Foo>::AMT); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + note: erroneous constant encountered --> $DIR/issue-44578.rs:25:20 | diff --git a/tests/ui/consts/const-eval/issue-50814.rs b/tests/ui/consts/const-eval/issue-50814.rs index ca26f51f111d3..27b5b39ad7371 100644 --- a/tests/ui/consts/const-eval/issue-50814.rs +++ b/tests/ui/consts/const-eval/issue-50814.rs @@ -14,6 +14,7 @@ struct Sum(A, B); impl Unsigned for Sum { const MAX: u8 = A::MAX + B::MAX; //~^ ERROR evaluation of ` as Unsigned>::MAX` failed + //~| ERROR evaluation of ` as Unsigned>::MAX` failed } fn foo(_: T) -> &'static u8 { diff --git a/tests/ui/consts/const-eval/issue-50814.stderr b/tests/ui/consts/const-eval/issue-50814.stderr index 65c49956f1859..8d01816140152 100644 --- a/tests/ui/consts/const-eval/issue-50814.stderr +++ b/tests/ui/consts/const-eval/issue-50814.stderr @@ -5,17 +5,33 @@ LL | const MAX: u8 = A::MAX + B::MAX; | ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow note: erroneous constant encountered - --> $DIR/issue-50814.rs:20:6 + --> $DIR/issue-50814.rs:21:6 | LL | &Sum::::MAX | ^^^^^^^^^^^^^^^^^^ +error[E0080]: evaluation of ` as Unsigned>::MAX` failed + --> $DIR/issue-50814.rs:15:21 + | +LL | const MAX: u8 = A::MAX + B::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +note: erroneous constant encountered + --> $DIR/issue-50814.rs:21:6 + | +LL | &Sum::::MAX + | ^^^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + note: the above error was encountered while instantiating `fn foo::` - --> $DIR/issue-50814.rs:25:5 + --> $DIR/issue-50814.rs:26:5 | LL | foo(0); | ^^^^^^ -error: aborting due to 1 previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/overflowing-consts.noopt.stderr b/tests/ui/consts/overflowing-consts.noopt.stderr new file mode 100644 index 0000000000000..81f22944adbe7 --- /dev/null +++ b/tests/ui/consts/overflowing-consts.noopt.stderr @@ -0,0 +1,1023 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:19:22 + | +LL | const _NI8_SHL: i8 = 1i8 << 8; + | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:20:26 + | +LL | const _NI8_SHL_P: &i8 = &(1i8 << 8); + | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:22:24 + | +LL | const _NI16_SHL: i16 = 1i16 << 16; + | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:23:28 + | +LL | const _NI16_SHL_P: &i16 = &(1i16 << 16); + | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:25:24 + | +LL | const _NI32_SHL: i32 = 1i32 << 32; + | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:26:28 + | +LL | const _NI32_SHL_P: &i32 = &(1i32 << 32); + | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:28:24 + | +LL | const _NI64_SHL: i64 = 1i64 << 64; + | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:29:28 + | +LL | const _NI64_SHL_P: &i64 = &(1i64 << 64); + | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:31:26 + | +LL | const _NI128_SHL: i128 = 1i128 << 128; + | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:32:30 + | +LL | const _NI128_SHL_P: &i128 = &(1i128 << 128); + | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:34:22 + | +LL | const _NU8_SHL: u8 = 1u8 << 8; + | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:35:26 + | +LL | const _NU8_SHL_P: &u8 = &(1u8 << 8); + | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:37:24 + | +LL | const _NU16_SHL: u16 = 1u16 << 16; + | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:38:28 + | +LL | const _NU16_SHL_P: &u16 = &(1u16 << 16); + | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:40:24 + | +LL | const _NU32_SHL: u32 = 1u32 << 32; + | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:41:28 + | +LL | const _NU32_SHL_P: &u32 = &(1u32 << 32); + | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:43:24 + | +LL | const _NU64_SHL: u64 = 1u64 << 64; + | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:44:28 + | +LL | const _NU64_SHL_P: &u64 = &(1u64 << 64); + | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:46:26 + | +LL | const _NU128_SHL: u128 = 1u128 << 128; + | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:47:30 + | +LL | const _NU128_SHL_P: &u128 = &(1u128 << 128); + | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:49:28 + | +LL | const _NISIZE_SHL: isize = 1isize << BITS; + | ^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:50:32 + | +LL | const _NISIZE_SHL_P: &isize = &(1isize << BITS); + | ^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:52:28 + | +LL | const _NUSIZE_SHL: usize = 1usize << BITS; + | ^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:53:32 + | +LL | const _NUSIZE_SHL_P: &usize = &(1usize << BITS); + | ^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:57:22 + | +LL | const _NI8_SHR: i8 = 1i8 >> 8; + | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:58:26 + | +LL | const _NI8_SHR_P: &i8 = &(1i8 >> 8); + | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:60:24 + | +LL | const _NI16_SHR: i16 = 1i16 >> 16; + | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:61:28 + | +LL | const _NI16_SHR_P: &i16 = &(1i16 >> 16); + | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:63:24 + | +LL | const _NI32_SHR: i32 = 1i32 >> 32; + | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:64:28 + | +LL | const _NI32_SHR_P: &i32 = &(1i32 >> 32); + | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:66:24 + | +LL | const _NI64_SHR: i64 = 1i64 >> 64; + | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:67:28 + | +LL | const _NI64_SHR_P: &i64 = &(1i64 >> 64); + | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:69:26 + | +LL | const _NI128_SHR: i128 = 1i128 >> 128; + | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:70:30 + | +LL | const _NI128_SHR_P: &i128 = &(1i128 >> 128); + | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:72:22 + | +LL | const _NU8_SHR: u8 = 1u8 >> 8; + | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:73:26 + | +LL | const _NU8_SHR_P: &u8 = &(1u8 >> 8); + | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:75:24 + | +LL | const _NU16_SHR: u16 = 1u16 >> 16; + | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:76:28 + | +LL | const _NU16_SHR_P: &u16 = &(1u16 >> 16); + | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:78:24 + | +LL | const _NU32_SHR: u32 = 1u32 >> 32; + | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:79:28 + | +LL | const _NU32_SHR_P: &u32 = &(1u32 >> 32); + | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:81:24 + | +LL | const _NU64_SHR: u64 = 1u64 >> 64; + | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:82:28 + | +LL | const _NU64_SHR_P: &u64 = &(1u64 >> 64); + | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:84:26 + | +LL | const _NU128_SHR: u128 = 1u128 >> 128; + | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:85:30 + | +LL | const _NU128_SHR_P: &u128 = &(1u128 >> 128); + | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:87:28 + | +LL | const _NISIZE_SHR: isize = 1isize >> BITS; + | ^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:88:32 + | +LL | const _NISIZE_SHR_P: &isize = &(1isize >> BITS); + | ^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:90:28 + | +LL | const _NUSIZE_SHR: usize = 1usize >> BITS; + | ^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:91:32 + | +LL | const _NUSIZE_SHR_P: &usize = &(1usize >> BITS); + | ^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:95:22 + | +LL | const _NI8_ADD: i8 = 1i8 + i8::MAX; + | ^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:96:26 + | +LL | const _NI8_ADD_P: &i8 = &(1i8 + i8::MAX); + | ^^^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:98:24 + | +LL | const _NI16_ADD: i16 = 1i16 + i16::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:99:28 + | +LL | const _NI16_ADD_P: &i16 = &(1i16 + i16::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:101:24 + | +LL | const _NI32_ADD: i32 = 1i32 + i32::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:102:28 + | +LL | const _NI32_ADD_P: &i32 = &(1i32 + i32::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:104:24 + | +LL | const _NI64_ADD: i64 = 1i64 + i64::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:105:28 + | +LL | const _NI64_ADD_P: &i64 = &(1i64 + i64::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:107:26 + | +LL | const _NI128_ADD: i128 = 1i128 + i128::MAX; + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:108:30 + | +LL | const _NI128_ADD_P: &i128 = &(1i128 + i128::MAX); + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:110:22 + | +LL | const _NU8_ADD: u8 = 1u8 + u8::MAX; + | ^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:111:26 + | +LL | const _NU8_ADD_P: &u8 = &(1u8 + u8::MAX); + | ^^^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:113:24 + | +LL | const _NU16_ADD: u16 = 1u16 + u16::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:114:28 + | +LL | const _NU16_ADD_P: &u16 = &(1u16 + u16::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:116:24 + | +LL | const _NU32_ADD: u32 = 1u32 + u32::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:117:28 + | +LL | const _NU32_ADD_P: &u32 = &(1u32 + u32::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:119:24 + | +LL | const _NU64_ADD: u64 = 1u64 + u64::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:120:28 + | +LL | const _NU64_ADD_P: &u64 = &(1u64 + u64::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:122:26 + | +LL | const _NU128_ADD: u128 = 1u128 + u128::MAX; + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:123:30 + | +LL | const _NU128_ADD_P: &u128 = &(1u128 + u128::MAX); + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:125:28 + | +LL | const _NISIZE_ADD: isize = 1isize + isize::MAX; + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:126:32 + | +LL | const _NISIZE_ADD_P: &isize = &(1isize + isize::MAX); + | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:128:28 + | +LL | const _NUSIZE_ADD: usize = 1usize + usize::MAX; + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:129:32 + | +LL | const _NUSIZE_ADD_P: &usize = &(1usize + usize::MAX); + | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:133:22 + | +LL | const _NI8_SUB: i8 = -5i8 - i8::MAX; + | ^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:134:26 + | +LL | const _NI8_SUB_P: &i8 = &(-5i8 - i8::MAX); + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:136:24 + | +LL | const _NI16_SUB: i16 = -5i16 - i16::MAX; + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:137:28 + | +LL | const _NI16_SUB_P: &i16 = &(-5i16 - i16::MAX); + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:139:24 + | +LL | const _NI32_SUB: i32 = -5i32 - i32::MAX; + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:140:28 + | +LL | const _NI32_SUB_P: &i32 = &(-5i32 - i32::MAX); + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:142:24 + | +LL | const _NI64_SUB: i64 = -5i64 - i64::MAX; + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:143:28 + | +LL | const _NI64_SUB_P: &i64 = &(-5i64 - i64::MAX); + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:145:26 + | +LL | const _NI128_SUB: i128 = -5i128 - i128::MAX; + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:146:30 + | +LL | const _NI128_SUB_P: &i128 = &(-5i128 - i128::MAX); + | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:148:22 + | +LL | const _NU8_SUB: u8 = 1u8 - 5; + | ^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:149:26 + | +LL | const _NU8_SUB_P: &u8 = &(1u8 - 5); + | ^^^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:151:24 + | +LL | const _NU16_SUB: u16 = 1u16 - 5; + | ^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:152:28 + | +LL | const _NU16_SUB_P: &u16 = &(1u16 - 5); + | ^^^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:154:24 + | +LL | const _NU32_SUB: u32 = 1u32 - 5; + | ^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:155:28 + | +LL | const _NU32_SUB_P: &u32 = &(1u32 - 5); + | ^^^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:157:24 + | +LL | const _NU64_SUB: u64 = 1u64 - 5; + | ^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:158:28 + | +LL | const _NU64_SUB_P: &u64 = &(1u64 - 5); + | ^^^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:160:26 + | +LL | const _NU128_SUB: u128 = 1u128 - 5; + | ^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:161:30 + | +LL | const _NU128_SUB_P: &u128 = &(1u128 - 5); + | ^^^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:163:28 + | +LL | const _NISIZE_SUB: isize = -5isize - isize::MAX; + | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:164:32 + | +LL | const _NISIZE_SUB_P: &isize = &(-5isize - isize::MAX); + | ^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:166:28 + | +LL | const _NUSIZE_SUB: usize = 1usize - 5 ; + | ^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:167:32 + | +LL | const _NUSIZE_SUB_P: &usize = &(1usize - 5 ); + | ^^^^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:171:22 + | +LL | const _NI8_MUL: i8 = i8::MAX * 5; + | ^^^^^^^^^^^ attempt to compute `i8::MAX * 5_i8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:172:26 + | +LL | const _NI8_MUL_P: &i8 = &(i8::MAX * 5); + | ^^^^^^^^^^^^^ attempt to compute `i8::MAX * 5_i8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:174:24 + | +LL | const _NI16_MUL: i16 = i16::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:175:28 + | +LL | const _NI16_MUL_P: &i16 = &(i16::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:177:24 + | +LL | const _NI32_MUL: i32 = i32::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:178:28 + | +LL | const _NI32_MUL_P: &i32 = &(i32::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:180:24 + | +LL | const _NI64_MUL: i64 = i64::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:181:28 + | +LL | const _NI64_MUL_P: &i64 = &(i64::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:183:26 + | +LL | const _NI128_MUL: i128 = i128::MAX * 5; + | ^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:184:30 + | +LL | const _NI128_MUL_P: &i128 = &(i128::MAX * 5); + | ^^^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:186:22 + | +LL | const _NU8_MUL: u8 = u8::MAX * 5; + | ^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:187:26 + | +LL | const _NU8_MUL_P: &u8 = &(u8::MAX * 5); + | ^^^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:189:24 + | +LL | const _NU16_MUL: u16 = u16::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:190:28 + | +LL | const _NU16_MUL_P: &u16 = &(u16::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:192:24 + | +LL | const _NU32_MUL: u32 = u32::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:193:28 + | +LL | const _NU32_MUL_P: &u32 = &(u32::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:195:24 + | +LL | const _NU64_MUL: u64 = u64::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:196:28 + | +LL | const _NU64_MUL_P: &u64 = &(u64::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:198:26 + | +LL | const _NU128_MUL: u128 = u128::MAX * 5; + | ^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:199:30 + | +LL | const _NU128_MUL_P: &u128 = &(u128::MAX * 5); + | ^^^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:201:28 + | +LL | const _NISIZE_MUL: isize = isize::MAX * 5; + | ^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:202:32 + | +LL | const _NISIZE_MUL_P: &isize = &(isize::MAX * 5); + | ^^^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:204:28 + | +LL | const _NUSIZE_MUL: usize = usize::MAX * 5; + | ^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:205:32 + | +LL | const _NUSIZE_MUL_P: &usize = &(usize::MAX * 5); + | ^^^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:209:22 + | +LL | const _NI8_DIV: i8 = 1i8 / 0; + | ^^^^^^^ attempt to divide `1_i8` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:210:26 + | +LL | const _NI8_DIV_P: &i8 = &(1i8 / 0); + | ^^^^^^^^^ attempt to divide `1_i8` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:212:24 + | +LL | const _NI16_DIV: i16 = 1i16 / 0; + | ^^^^^^^^ attempt to divide `1_i16` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:213:28 + | +LL | const _NI16_DIV_P: &i16 = &(1i16 / 0); + | ^^^^^^^^^^ attempt to divide `1_i16` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:215:24 + | +LL | const _NI32_DIV: i32 = 1i32 / 0; + | ^^^^^^^^ attempt to divide `1_i32` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:216:28 + | +LL | const _NI32_DIV_P: &i32 = &(1i32 / 0); + | ^^^^^^^^^^ attempt to divide `1_i32` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:218:24 + | +LL | const _NI64_DIV: i64 = 1i64 / 0; + | ^^^^^^^^ attempt to divide `1_i64` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:219:28 + | +LL | const _NI64_DIV_P: &i64 = &(1i64 / 0); + | ^^^^^^^^^^ attempt to divide `1_i64` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:221:26 + | +LL | const _NI128_DIV: i128 = 1i128 / 0; + | ^^^^^^^^^ attempt to divide `1_i128` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:222:30 + | +LL | const _NI128_DIV_P: &i128 = &(1i128 / 0); + | ^^^^^^^^^^^ attempt to divide `1_i128` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:224:22 + | +LL | const _NU8_DIV: u8 = 1u8 / 0; + | ^^^^^^^ attempt to divide `1_u8` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:225:26 + | +LL | const _NU8_DIV_P: &u8 = &(1u8 / 0); + | ^^^^^^^^^ attempt to divide `1_u8` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:227:24 + | +LL | const _NU16_DIV: u16 = 1u16 / 0; + | ^^^^^^^^ attempt to divide `1_u16` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:228:28 + | +LL | const _NU16_DIV_P: &u16 = &(1u16 / 0); + | ^^^^^^^^^^ attempt to divide `1_u16` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:230:24 + | +LL | const _NU32_DIV: u32 = 1u32 / 0; + | ^^^^^^^^ attempt to divide `1_u32` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:231:28 + | +LL | const _NU32_DIV_P: &u32 = &(1u32 / 0); + | ^^^^^^^^^^ attempt to divide `1_u32` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:233:24 + | +LL | const _NU64_DIV: u64 = 1u64 / 0; + | ^^^^^^^^ attempt to divide `1_u64` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:234:28 + | +LL | const _NU64_DIV_P: &u64 = &(1u64 / 0); + | ^^^^^^^^^^ attempt to divide `1_u64` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:236:26 + | +LL | const _NU128_DIV: u128 = 1u128 / 0; + | ^^^^^^^^^ attempt to divide `1_u128` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:237:30 + | +LL | const _NU128_DIV_P: &u128 = &(1u128 / 0); + | ^^^^^^^^^^^ attempt to divide `1_u128` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:239:28 + | +LL | const _NISIZE_DIV: isize = 1isize / 0; + | ^^^^^^^^^^ attempt to divide `1_isize` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:240:32 + | +LL | const _NISIZE_DIV_P: &isize = &(1isize / 0); + | ^^^^^^^^^^^^ attempt to divide `1_isize` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:242:28 + | +LL | const _NUSIZE_DIV: usize = 1usize / 0; + | ^^^^^^^^^^ attempt to divide `1_usize` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:243:32 + | +LL | const _NUSIZE_DIV_P: &usize = &(1usize / 0); + | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:246:22 + | +LL | const _NI8_MOD: i8 = 1i8 % 0; + | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:247:26 + | +LL | const _NI8_MOD_P: &i8 = &(1i8 % 0); + | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:249:24 + | +LL | const _NI16_MOD: i16 = 1i16 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:250:28 + | +LL | const _NI16_MOD_P: &i16 = &(1i16 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:252:24 + | +LL | const _NI32_MOD: i32 = 1i32 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:253:28 + | +LL | const _NI32_MOD_P: &i32 = &(1i32 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:255:24 + | +LL | const _NI64_MOD: i64 = 1i64 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:256:28 + | +LL | const _NI64_MOD_P: &i64 = &(1i64 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:258:26 + | +LL | const _NI128_MOD: i128 = 1i128 % 0; + | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:259:30 + | +LL | const _NI128_MOD_P: &i128 = &(1i128 % 0); + | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:261:22 + | +LL | const _NU8_MOD: u8 = 1u8 % 0; + | ^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:262:26 + | +LL | const _NU8_MOD_P: &u8 = &(1u8 % 0); + | ^^^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:264:24 + | +LL | const _NU16_MOD: u16 = 1u16 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:265:28 + | +LL | const _NU16_MOD_P: &u16 = &(1u16 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:267:24 + | +LL | const _NU32_MOD: u32 = 1u32 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:268:28 + | +LL | const _NU32_MOD_P: &u32 = &(1u32 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:270:24 + | +LL | const _NU64_MOD: u64 = 1u64 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:271:28 + | +LL | const _NU64_MOD_P: &u64 = &(1u64 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:273:26 + | +LL | const _NU128_MOD: u128 = 1u128 % 0; + | ^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:274:30 + | +LL | const _NU128_MOD_P: &u128 = &(1u128 % 0); + | ^^^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:276:28 + | +LL | const _NISIZE_MOD: isize = 1isize % 0; + | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:277:32 + | +LL | const _NISIZE_MOD_P: &isize = &(1isize % 0); + | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:279:28 + | +LL | const _NUSIZE_MOD: usize = 1usize % 0; + | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:280:32 + | +LL | const _NUSIZE_MOD_P: &usize = &(1usize % 0); + | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:284:24 + | +LL | const _NI32_OOB: i32 = [1, 2, 3][4]; + | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:285:28 + | +LL | const _NI32_OOB_P: &i32 = &([1, 2, 3][4]); + | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + +error: aborting due to 170 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/overflowing-consts.opt.stderr b/tests/ui/consts/overflowing-consts.opt.stderr new file mode 100644 index 0000000000000..81f22944adbe7 --- /dev/null +++ b/tests/ui/consts/overflowing-consts.opt.stderr @@ -0,0 +1,1023 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:19:22 + | +LL | const _NI8_SHL: i8 = 1i8 << 8; + | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:20:26 + | +LL | const _NI8_SHL_P: &i8 = &(1i8 << 8); + | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:22:24 + | +LL | const _NI16_SHL: i16 = 1i16 << 16; + | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:23:28 + | +LL | const _NI16_SHL_P: &i16 = &(1i16 << 16); + | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:25:24 + | +LL | const _NI32_SHL: i32 = 1i32 << 32; + | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:26:28 + | +LL | const _NI32_SHL_P: &i32 = &(1i32 << 32); + | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:28:24 + | +LL | const _NI64_SHL: i64 = 1i64 << 64; + | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:29:28 + | +LL | const _NI64_SHL_P: &i64 = &(1i64 << 64); + | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:31:26 + | +LL | const _NI128_SHL: i128 = 1i128 << 128; + | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:32:30 + | +LL | const _NI128_SHL_P: &i128 = &(1i128 << 128); + | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:34:22 + | +LL | const _NU8_SHL: u8 = 1u8 << 8; + | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:35:26 + | +LL | const _NU8_SHL_P: &u8 = &(1u8 << 8); + | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:37:24 + | +LL | const _NU16_SHL: u16 = 1u16 << 16; + | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:38:28 + | +LL | const _NU16_SHL_P: &u16 = &(1u16 << 16); + | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:40:24 + | +LL | const _NU32_SHL: u32 = 1u32 << 32; + | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:41:28 + | +LL | const _NU32_SHL_P: &u32 = &(1u32 << 32); + | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:43:24 + | +LL | const _NU64_SHL: u64 = 1u64 << 64; + | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:44:28 + | +LL | const _NU64_SHL_P: &u64 = &(1u64 << 64); + | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:46:26 + | +LL | const _NU128_SHL: u128 = 1u128 << 128; + | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:47:30 + | +LL | const _NU128_SHL_P: &u128 = &(1u128 << 128); + | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:49:28 + | +LL | const _NISIZE_SHL: isize = 1isize << BITS; + | ^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:50:32 + | +LL | const _NISIZE_SHL_P: &isize = &(1isize << BITS); + | ^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:52:28 + | +LL | const _NUSIZE_SHL: usize = 1usize << BITS; + | ^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:53:32 + | +LL | const _NUSIZE_SHL_P: &usize = &(1usize << BITS); + | ^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:57:22 + | +LL | const _NI8_SHR: i8 = 1i8 >> 8; + | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:58:26 + | +LL | const _NI8_SHR_P: &i8 = &(1i8 >> 8); + | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:60:24 + | +LL | const _NI16_SHR: i16 = 1i16 >> 16; + | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:61:28 + | +LL | const _NI16_SHR_P: &i16 = &(1i16 >> 16); + | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:63:24 + | +LL | const _NI32_SHR: i32 = 1i32 >> 32; + | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:64:28 + | +LL | const _NI32_SHR_P: &i32 = &(1i32 >> 32); + | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:66:24 + | +LL | const _NI64_SHR: i64 = 1i64 >> 64; + | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:67:28 + | +LL | const _NI64_SHR_P: &i64 = &(1i64 >> 64); + | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:69:26 + | +LL | const _NI128_SHR: i128 = 1i128 >> 128; + | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:70:30 + | +LL | const _NI128_SHR_P: &i128 = &(1i128 >> 128); + | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:72:22 + | +LL | const _NU8_SHR: u8 = 1u8 >> 8; + | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:73:26 + | +LL | const _NU8_SHR_P: &u8 = &(1u8 >> 8); + | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:75:24 + | +LL | const _NU16_SHR: u16 = 1u16 >> 16; + | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:76:28 + | +LL | const _NU16_SHR_P: &u16 = &(1u16 >> 16); + | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:78:24 + | +LL | const _NU32_SHR: u32 = 1u32 >> 32; + | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:79:28 + | +LL | const _NU32_SHR_P: &u32 = &(1u32 >> 32); + | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:81:24 + | +LL | const _NU64_SHR: u64 = 1u64 >> 64; + | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:82:28 + | +LL | const _NU64_SHR_P: &u64 = &(1u64 >> 64); + | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:84:26 + | +LL | const _NU128_SHR: u128 = 1u128 >> 128; + | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:85:30 + | +LL | const _NU128_SHR_P: &u128 = &(1u128 >> 128); + | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:87:28 + | +LL | const _NISIZE_SHR: isize = 1isize >> BITS; + | ^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:88:32 + | +LL | const _NISIZE_SHR_P: &isize = &(1isize >> BITS); + | ^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:90:28 + | +LL | const _NUSIZE_SHR: usize = 1usize >> BITS; + | ^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:91:32 + | +LL | const _NUSIZE_SHR_P: &usize = &(1usize >> BITS); + | ^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:95:22 + | +LL | const _NI8_ADD: i8 = 1i8 + i8::MAX; + | ^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:96:26 + | +LL | const _NI8_ADD_P: &i8 = &(1i8 + i8::MAX); + | ^^^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:98:24 + | +LL | const _NI16_ADD: i16 = 1i16 + i16::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:99:28 + | +LL | const _NI16_ADD_P: &i16 = &(1i16 + i16::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:101:24 + | +LL | const _NI32_ADD: i32 = 1i32 + i32::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:102:28 + | +LL | const _NI32_ADD_P: &i32 = &(1i32 + i32::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:104:24 + | +LL | const _NI64_ADD: i64 = 1i64 + i64::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:105:28 + | +LL | const _NI64_ADD_P: &i64 = &(1i64 + i64::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:107:26 + | +LL | const _NI128_ADD: i128 = 1i128 + i128::MAX; + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:108:30 + | +LL | const _NI128_ADD_P: &i128 = &(1i128 + i128::MAX); + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:110:22 + | +LL | const _NU8_ADD: u8 = 1u8 + u8::MAX; + | ^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:111:26 + | +LL | const _NU8_ADD_P: &u8 = &(1u8 + u8::MAX); + | ^^^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:113:24 + | +LL | const _NU16_ADD: u16 = 1u16 + u16::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:114:28 + | +LL | const _NU16_ADD_P: &u16 = &(1u16 + u16::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:116:24 + | +LL | const _NU32_ADD: u32 = 1u32 + u32::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:117:28 + | +LL | const _NU32_ADD_P: &u32 = &(1u32 + u32::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:119:24 + | +LL | const _NU64_ADD: u64 = 1u64 + u64::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:120:28 + | +LL | const _NU64_ADD_P: &u64 = &(1u64 + u64::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:122:26 + | +LL | const _NU128_ADD: u128 = 1u128 + u128::MAX; + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:123:30 + | +LL | const _NU128_ADD_P: &u128 = &(1u128 + u128::MAX); + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:125:28 + | +LL | const _NISIZE_ADD: isize = 1isize + isize::MAX; + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:126:32 + | +LL | const _NISIZE_ADD_P: &isize = &(1isize + isize::MAX); + | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:128:28 + | +LL | const _NUSIZE_ADD: usize = 1usize + usize::MAX; + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:129:32 + | +LL | const _NUSIZE_ADD_P: &usize = &(1usize + usize::MAX); + | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:133:22 + | +LL | const _NI8_SUB: i8 = -5i8 - i8::MAX; + | ^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:134:26 + | +LL | const _NI8_SUB_P: &i8 = &(-5i8 - i8::MAX); + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:136:24 + | +LL | const _NI16_SUB: i16 = -5i16 - i16::MAX; + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:137:28 + | +LL | const _NI16_SUB_P: &i16 = &(-5i16 - i16::MAX); + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:139:24 + | +LL | const _NI32_SUB: i32 = -5i32 - i32::MAX; + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:140:28 + | +LL | const _NI32_SUB_P: &i32 = &(-5i32 - i32::MAX); + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:142:24 + | +LL | const _NI64_SUB: i64 = -5i64 - i64::MAX; + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:143:28 + | +LL | const _NI64_SUB_P: &i64 = &(-5i64 - i64::MAX); + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:145:26 + | +LL | const _NI128_SUB: i128 = -5i128 - i128::MAX; + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:146:30 + | +LL | const _NI128_SUB_P: &i128 = &(-5i128 - i128::MAX); + | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:148:22 + | +LL | const _NU8_SUB: u8 = 1u8 - 5; + | ^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:149:26 + | +LL | const _NU8_SUB_P: &u8 = &(1u8 - 5); + | ^^^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:151:24 + | +LL | const _NU16_SUB: u16 = 1u16 - 5; + | ^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:152:28 + | +LL | const _NU16_SUB_P: &u16 = &(1u16 - 5); + | ^^^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:154:24 + | +LL | const _NU32_SUB: u32 = 1u32 - 5; + | ^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:155:28 + | +LL | const _NU32_SUB_P: &u32 = &(1u32 - 5); + | ^^^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:157:24 + | +LL | const _NU64_SUB: u64 = 1u64 - 5; + | ^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:158:28 + | +LL | const _NU64_SUB_P: &u64 = &(1u64 - 5); + | ^^^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:160:26 + | +LL | const _NU128_SUB: u128 = 1u128 - 5; + | ^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:161:30 + | +LL | const _NU128_SUB_P: &u128 = &(1u128 - 5); + | ^^^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:163:28 + | +LL | const _NISIZE_SUB: isize = -5isize - isize::MAX; + | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:164:32 + | +LL | const _NISIZE_SUB_P: &isize = &(-5isize - isize::MAX); + | ^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:166:28 + | +LL | const _NUSIZE_SUB: usize = 1usize - 5 ; + | ^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:167:32 + | +LL | const _NUSIZE_SUB_P: &usize = &(1usize - 5 ); + | ^^^^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:171:22 + | +LL | const _NI8_MUL: i8 = i8::MAX * 5; + | ^^^^^^^^^^^ attempt to compute `i8::MAX * 5_i8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:172:26 + | +LL | const _NI8_MUL_P: &i8 = &(i8::MAX * 5); + | ^^^^^^^^^^^^^ attempt to compute `i8::MAX * 5_i8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:174:24 + | +LL | const _NI16_MUL: i16 = i16::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:175:28 + | +LL | const _NI16_MUL_P: &i16 = &(i16::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:177:24 + | +LL | const _NI32_MUL: i32 = i32::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:178:28 + | +LL | const _NI32_MUL_P: &i32 = &(i32::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:180:24 + | +LL | const _NI64_MUL: i64 = i64::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:181:28 + | +LL | const _NI64_MUL_P: &i64 = &(i64::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:183:26 + | +LL | const _NI128_MUL: i128 = i128::MAX * 5; + | ^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:184:30 + | +LL | const _NI128_MUL_P: &i128 = &(i128::MAX * 5); + | ^^^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:186:22 + | +LL | const _NU8_MUL: u8 = u8::MAX * 5; + | ^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:187:26 + | +LL | const _NU8_MUL_P: &u8 = &(u8::MAX * 5); + | ^^^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:189:24 + | +LL | const _NU16_MUL: u16 = u16::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:190:28 + | +LL | const _NU16_MUL_P: &u16 = &(u16::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:192:24 + | +LL | const _NU32_MUL: u32 = u32::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:193:28 + | +LL | const _NU32_MUL_P: &u32 = &(u32::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:195:24 + | +LL | const _NU64_MUL: u64 = u64::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:196:28 + | +LL | const _NU64_MUL_P: &u64 = &(u64::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:198:26 + | +LL | const _NU128_MUL: u128 = u128::MAX * 5; + | ^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:199:30 + | +LL | const _NU128_MUL_P: &u128 = &(u128::MAX * 5); + | ^^^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:201:28 + | +LL | const _NISIZE_MUL: isize = isize::MAX * 5; + | ^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:202:32 + | +LL | const _NISIZE_MUL_P: &isize = &(isize::MAX * 5); + | ^^^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:204:28 + | +LL | const _NUSIZE_MUL: usize = usize::MAX * 5; + | ^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:205:32 + | +LL | const _NUSIZE_MUL_P: &usize = &(usize::MAX * 5); + | ^^^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:209:22 + | +LL | const _NI8_DIV: i8 = 1i8 / 0; + | ^^^^^^^ attempt to divide `1_i8` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:210:26 + | +LL | const _NI8_DIV_P: &i8 = &(1i8 / 0); + | ^^^^^^^^^ attempt to divide `1_i8` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:212:24 + | +LL | const _NI16_DIV: i16 = 1i16 / 0; + | ^^^^^^^^ attempt to divide `1_i16` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:213:28 + | +LL | const _NI16_DIV_P: &i16 = &(1i16 / 0); + | ^^^^^^^^^^ attempt to divide `1_i16` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:215:24 + | +LL | const _NI32_DIV: i32 = 1i32 / 0; + | ^^^^^^^^ attempt to divide `1_i32` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:216:28 + | +LL | const _NI32_DIV_P: &i32 = &(1i32 / 0); + | ^^^^^^^^^^ attempt to divide `1_i32` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:218:24 + | +LL | const _NI64_DIV: i64 = 1i64 / 0; + | ^^^^^^^^ attempt to divide `1_i64` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:219:28 + | +LL | const _NI64_DIV_P: &i64 = &(1i64 / 0); + | ^^^^^^^^^^ attempt to divide `1_i64` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:221:26 + | +LL | const _NI128_DIV: i128 = 1i128 / 0; + | ^^^^^^^^^ attempt to divide `1_i128` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:222:30 + | +LL | const _NI128_DIV_P: &i128 = &(1i128 / 0); + | ^^^^^^^^^^^ attempt to divide `1_i128` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:224:22 + | +LL | const _NU8_DIV: u8 = 1u8 / 0; + | ^^^^^^^ attempt to divide `1_u8` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:225:26 + | +LL | const _NU8_DIV_P: &u8 = &(1u8 / 0); + | ^^^^^^^^^ attempt to divide `1_u8` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:227:24 + | +LL | const _NU16_DIV: u16 = 1u16 / 0; + | ^^^^^^^^ attempt to divide `1_u16` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:228:28 + | +LL | const _NU16_DIV_P: &u16 = &(1u16 / 0); + | ^^^^^^^^^^ attempt to divide `1_u16` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:230:24 + | +LL | const _NU32_DIV: u32 = 1u32 / 0; + | ^^^^^^^^ attempt to divide `1_u32` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:231:28 + | +LL | const _NU32_DIV_P: &u32 = &(1u32 / 0); + | ^^^^^^^^^^ attempt to divide `1_u32` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:233:24 + | +LL | const _NU64_DIV: u64 = 1u64 / 0; + | ^^^^^^^^ attempt to divide `1_u64` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:234:28 + | +LL | const _NU64_DIV_P: &u64 = &(1u64 / 0); + | ^^^^^^^^^^ attempt to divide `1_u64` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:236:26 + | +LL | const _NU128_DIV: u128 = 1u128 / 0; + | ^^^^^^^^^ attempt to divide `1_u128` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:237:30 + | +LL | const _NU128_DIV_P: &u128 = &(1u128 / 0); + | ^^^^^^^^^^^ attempt to divide `1_u128` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:239:28 + | +LL | const _NISIZE_DIV: isize = 1isize / 0; + | ^^^^^^^^^^ attempt to divide `1_isize` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:240:32 + | +LL | const _NISIZE_DIV_P: &isize = &(1isize / 0); + | ^^^^^^^^^^^^ attempt to divide `1_isize` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:242:28 + | +LL | const _NUSIZE_DIV: usize = 1usize / 0; + | ^^^^^^^^^^ attempt to divide `1_usize` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:243:32 + | +LL | const _NUSIZE_DIV_P: &usize = &(1usize / 0); + | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:246:22 + | +LL | const _NI8_MOD: i8 = 1i8 % 0; + | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:247:26 + | +LL | const _NI8_MOD_P: &i8 = &(1i8 % 0); + | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:249:24 + | +LL | const _NI16_MOD: i16 = 1i16 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:250:28 + | +LL | const _NI16_MOD_P: &i16 = &(1i16 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:252:24 + | +LL | const _NI32_MOD: i32 = 1i32 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:253:28 + | +LL | const _NI32_MOD_P: &i32 = &(1i32 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:255:24 + | +LL | const _NI64_MOD: i64 = 1i64 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:256:28 + | +LL | const _NI64_MOD_P: &i64 = &(1i64 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:258:26 + | +LL | const _NI128_MOD: i128 = 1i128 % 0; + | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:259:30 + | +LL | const _NI128_MOD_P: &i128 = &(1i128 % 0); + | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:261:22 + | +LL | const _NU8_MOD: u8 = 1u8 % 0; + | ^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:262:26 + | +LL | const _NU8_MOD_P: &u8 = &(1u8 % 0); + | ^^^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:264:24 + | +LL | const _NU16_MOD: u16 = 1u16 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:265:28 + | +LL | const _NU16_MOD_P: &u16 = &(1u16 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:267:24 + | +LL | const _NU32_MOD: u32 = 1u32 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:268:28 + | +LL | const _NU32_MOD_P: &u32 = &(1u32 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:270:24 + | +LL | const _NU64_MOD: u64 = 1u64 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:271:28 + | +LL | const _NU64_MOD_P: &u64 = &(1u64 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:273:26 + | +LL | const _NU128_MOD: u128 = 1u128 % 0; + | ^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:274:30 + | +LL | const _NU128_MOD_P: &u128 = &(1u128 % 0); + | ^^^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:276:28 + | +LL | const _NISIZE_MOD: isize = 1isize % 0; + | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:277:32 + | +LL | const _NISIZE_MOD_P: &isize = &(1isize % 0); + | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:279:28 + | +LL | const _NUSIZE_MOD: usize = 1usize % 0; + | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:280:32 + | +LL | const _NUSIZE_MOD_P: &usize = &(1usize % 0); + | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:284:24 + | +LL | const _NI32_OOB: i32 = [1, 2, 3][4]; + | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:285:28 + | +LL | const _NI32_OOB_P: &i32 = &([1, 2, 3][4]); + | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + +error: aborting due to 170 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/overflowing-consts.opt_with_overflow_checks.stderr b/tests/ui/consts/overflowing-consts.opt_with_overflow_checks.stderr new file mode 100644 index 0000000000000..81f22944adbe7 --- /dev/null +++ b/tests/ui/consts/overflowing-consts.opt_with_overflow_checks.stderr @@ -0,0 +1,1023 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:19:22 + | +LL | const _NI8_SHL: i8 = 1i8 << 8; + | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:20:26 + | +LL | const _NI8_SHL_P: &i8 = &(1i8 << 8); + | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:22:24 + | +LL | const _NI16_SHL: i16 = 1i16 << 16; + | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:23:28 + | +LL | const _NI16_SHL_P: &i16 = &(1i16 << 16); + | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:25:24 + | +LL | const _NI32_SHL: i32 = 1i32 << 32; + | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:26:28 + | +LL | const _NI32_SHL_P: &i32 = &(1i32 << 32); + | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:28:24 + | +LL | const _NI64_SHL: i64 = 1i64 << 64; + | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:29:28 + | +LL | const _NI64_SHL_P: &i64 = &(1i64 << 64); + | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:31:26 + | +LL | const _NI128_SHL: i128 = 1i128 << 128; + | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:32:30 + | +LL | const _NI128_SHL_P: &i128 = &(1i128 << 128); + | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:34:22 + | +LL | const _NU8_SHL: u8 = 1u8 << 8; + | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:35:26 + | +LL | const _NU8_SHL_P: &u8 = &(1u8 << 8); + | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:37:24 + | +LL | const _NU16_SHL: u16 = 1u16 << 16; + | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:38:28 + | +LL | const _NU16_SHL_P: &u16 = &(1u16 << 16); + | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:40:24 + | +LL | const _NU32_SHL: u32 = 1u32 << 32; + | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:41:28 + | +LL | const _NU32_SHL_P: &u32 = &(1u32 << 32); + | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:43:24 + | +LL | const _NU64_SHL: u64 = 1u64 << 64; + | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:44:28 + | +LL | const _NU64_SHL_P: &u64 = &(1u64 << 64); + | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:46:26 + | +LL | const _NU128_SHL: u128 = 1u128 << 128; + | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:47:30 + | +LL | const _NU128_SHL_P: &u128 = &(1u128 << 128); + | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:49:28 + | +LL | const _NISIZE_SHL: isize = 1isize << BITS; + | ^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:50:32 + | +LL | const _NISIZE_SHL_P: &isize = &(1isize << BITS); + | ^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:52:28 + | +LL | const _NUSIZE_SHL: usize = 1usize << BITS; + | ^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:53:32 + | +LL | const _NUSIZE_SHL_P: &usize = &(1usize << BITS); + | ^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:57:22 + | +LL | const _NI8_SHR: i8 = 1i8 >> 8; + | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:58:26 + | +LL | const _NI8_SHR_P: &i8 = &(1i8 >> 8); + | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:60:24 + | +LL | const _NI16_SHR: i16 = 1i16 >> 16; + | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:61:28 + | +LL | const _NI16_SHR_P: &i16 = &(1i16 >> 16); + | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:63:24 + | +LL | const _NI32_SHR: i32 = 1i32 >> 32; + | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:64:28 + | +LL | const _NI32_SHR_P: &i32 = &(1i32 >> 32); + | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:66:24 + | +LL | const _NI64_SHR: i64 = 1i64 >> 64; + | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:67:28 + | +LL | const _NI64_SHR_P: &i64 = &(1i64 >> 64); + | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:69:26 + | +LL | const _NI128_SHR: i128 = 1i128 >> 128; + | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:70:30 + | +LL | const _NI128_SHR_P: &i128 = &(1i128 >> 128); + | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:72:22 + | +LL | const _NU8_SHR: u8 = 1u8 >> 8; + | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:73:26 + | +LL | const _NU8_SHR_P: &u8 = &(1u8 >> 8); + | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:75:24 + | +LL | const _NU16_SHR: u16 = 1u16 >> 16; + | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:76:28 + | +LL | const _NU16_SHR_P: &u16 = &(1u16 >> 16); + | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:78:24 + | +LL | const _NU32_SHR: u32 = 1u32 >> 32; + | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:79:28 + | +LL | const _NU32_SHR_P: &u32 = &(1u32 >> 32); + | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:81:24 + | +LL | const _NU64_SHR: u64 = 1u64 >> 64; + | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:82:28 + | +LL | const _NU64_SHR_P: &u64 = &(1u64 >> 64); + | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:84:26 + | +LL | const _NU128_SHR: u128 = 1u128 >> 128; + | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:85:30 + | +LL | const _NU128_SHR_P: &u128 = &(1u128 >> 128); + | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:87:28 + | +LL | const _NISIZE_SHR: isize = 1isize >> BITS; + | ^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:88:32 + | +LL | const _NISIZE_SHR_P: &isize = &(1isize >> BITS); + | ^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:90:28 + | +LL | const _NUSIZE_SHR: usize = 1usize >> BITS; + | ^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:91:32 + | +LL | const _NUSIZE_SHR_P: &usize = &(1usize >> BITS); + | ^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:95:22 + | +LL | const _NI8_ADD: i8 = 1i8 + i8::MAX; + | ^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:96:26 + | +LL | const _NI8_ADD_P: &i8 = &(1i8 + i8::MAX); + | ^^^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:98:24 + | +LL | const _NI16_ADD: i16 = 1i16 + i16::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:99:28 + | +LL | const _NI16_ADD_P: &i16 = &(1i16 + i16::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:101:24 + | +LL | const _NI32_ADD: i32 = 1i32 + i32::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:102:28 + | +LL | const _NI32_ADD_P: &i32 = &(1i32 + i32::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:104:24 + | +LL | const _NI64_ADD: i64 = 1i64 + i64::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:105:28 + | +LL | const _NI64_ADD_P: &i64 = &(1i64 + i64::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:107:26 + | +LL | const _NI128_ADD: i128 = 1i128 + i128::MAX; + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:108:30 + | +LL | const _NI128_ADD_P: &i128 = &(1i128 + i128::MAX); + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:110:22 + | +LL | const _NU8_ADD: u8 = 1u8 + u8::MAX; + | ^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:111:26 + | +LL | const _NU8_ADD_P: &u8 = &(1u8 + u8::MAX); + | ^^^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:113:24 + | +LL | const _NU16_ADD: u16 = 1u16 + u16::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:114:28 + | +LL | const _NU16_ADD_P: &u16 = &(1u16 + u16::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:116:24 + | +LL | const _NU32_ADD: u32 = 1u32 + u32::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:117:28 + | +LL | const _NU32_ADD_P: &u32 = &(1u32 + u32::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:119:24 + | +LL | const _NU64_ADD: u64 = 1u64 + u64::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:120:28 + | +LL | const _NU64_ADD_P: &u64 = &(1u64 + u64::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:122:26 + | +LL | const _NU128_ADD: u128 = 1u128 + u128::MAX; + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:123:30 + | +LL | const _NU128_ADD_P: &u128 = &(1u128 + u128::MAX); + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:125:28 + | +LL | const _NISIZE_ADD: isize = 1isize + isize::MAX; + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:126:32 + | +LL | const _NISIZE_ADD_P: &isize = &(1isize + isize::MAX); + | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:128:28 + | +LL | const _NUSIZE_ADD: usize = 1usize + usize::MAX; + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:129:32 + | +LL | const _NUSIZE_ADD_P: &usize = &(1usize + usize::MAX); + | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:133:22 + | +LL | const _NI8_SUB: i8 = -5i8 - i8::MAX; + | ^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:134:26 + | +LL | const _NI8_SUB_P: &i8 = &(-5i8 - i8::MAX); + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:136:24 + | +LL | const _NI16_SUB: i16 = -5i16 - i16::MAX; + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:137:28 + | +LL | const _NI16_SUB_P: &i16 = &(-5i16 - i16::MAX); + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:139:24 + | +LL | const _NI32_SUB: i32 = -5i32 - i32::MAX; + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:140:28 + | +LL | const _NI32_SUB_P: &i32 = &(-5i32 - i32::MAX); + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:142:24 + | +LL | const _NI64_SUB: i64 = -5i64 - i64::MAX; + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:143:28 + | +LL | const _NI64_SUB_P: &i64 = &(-5i64 - i64::MAX); + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:145:26 + | +LL | const _NI128_SUB: i128 = -5i128 - i128::MAX; + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:146:30 + | +LL | const _NI128_SUB_P: &i128 = &(-5i128 - i128::MAX); + | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:148:22 + | +LL | const _NU8_SUB: u8 = 1u8 - 5; + | ^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:149:26 + | +LL | const _NU8_SUB_P: &u8 = &(1u8 - 5); + | ^^^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:151:24 + | +LL | const _NU16_SUB: u16 = 1u16 - 5; + | ^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:152:28 + | +LL | const _NU16_SUB_P: &u16 = &(1u16 - 5); + | ^^^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:154:24 + | +LL | const _NU32_SUB: u32 = 1u32 - 5; + | ^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:155:28 + | +LL | const _NU32_SUB_P: &u32 = &(1u32 - 5); + | ^^^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:157:24 + | +LL | const _NU64_SUB: u64 = 1u64 - 5; + | ^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:158:28 + | +LL | const _NU64_SUB_P: &u64 = &(1u64 - 5); + | ^^^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:160:26 + | +LL | const _NU128_SUB: u128 = 1u128 - 5; + | ^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:161:30 + | +LL | const _NU128_SUB_P: &u128 = &(1u128 - 5); + | ^^^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:163:28 + | +LL | const _NISIZE_SUB: isize = -5isize - isize::MAX; + | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:164:32 + | +LL | const _NISIZE_SUB_P: &isize = &(-5isize - isize::MAX); + | ^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:166:28 + | +LL | const _NUSIZE_SUB: usize = 1usize - 5 ; + | ^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:167:32 + | +LL | const _NUSIZE_SUB_P: &usize = &(1usize - 5 ); + | ^^^^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:171:22 + | +LL | const _NI8_MUL: i8 = i8::MAX * 5; + | ^^^^^^^^^^^ attempt to compute `i8::MAX * 5_i8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:172:26 + | +LL | const _NI8_MUL_P: &i8 = &(i8::MAX * 5); + | ^^^^^^^^^^^^^ attempt to compute `i8::MAX * 5_i8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:174:24 + | +LL | const _NI16_MUL: i16 = i16::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:175:28 + | +LL | const _NI16_MUL_P: &i16 = &(i16::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:177:24 + | +LL | const _NI32_MUL: i32 = i32::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:178:28 + | +LL | const _NI32_MUL_P: &i32 = &(i32::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:180:24 + | +LL | const _NI64_MUL: i64 = i64::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:181:28 + | +LL | const _NI64_MUL_P: &i64 = &(i64::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:183:26 + | +LL | const _NI128_MUL: i128 = i128::MAX * 5; + | ^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:184:30 + | +LL | const _NI128_MUL_P: &i128 = &(i128::MAX * 5); + | ^^^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:186:22 + | +LL | const _NU8_MUL: u8 = u8::MAX * 5; + | ^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:187:26 + | +LL | const _NU8_MUL_P: &u8 = &(u8::MAX * 5); + | ^^^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:189:24 + | +LL | const _NU16_MUL: u16 = u16::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:190:28 + | +LL | const _NU16_MUL_P: &u16 = &(u16::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:192:24 + | +LL | const _NU32_MUL: u32 = u32::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:193:28 + | +LL | const _NU32_MUL_P: &u32 = &(u32::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:195:24 + | +LL | const _NU64_MUL: u64 = u64::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:196:28 + | +LL | const _NU64_MUL_P: &u64 = &(u64::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:198:26 + | +LL | const _NU128_MUL: u128 = u128::MAX * 5; + | ^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:199:30 + | +LL | const _NU128_MUL_P: &u128 = &(u128::MAX * 5); + | ^^^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:201:28 + | +LL | const _NISIZE_MUL: isize = isize::MAX * 5; + | ^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:202:32 + | +LL | const _NISIZE_MUL_P: &isize = &(isize::MAX * 5); + | ^^^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:204:28 + | +LL | const _NUSIZE_MUL: usize = usize::MAX * 5; + | ^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:205:32 + | +LL | const _NUSIZE_MUL_P: &usize = &(usize::MAX * 5); + | ^^^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:209:22 + | +LL | const _NI8_DIV: i8 = 1i8 / 0; + | ^^^^^^^ attempt to divide `1_i8` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:210:26 + | +LL | const _NI8_DIV_P: &i8 = &(1i8 / 0); + | ^^^^^^^^^ attempt to divide `1_i8` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:212:24 + | +LL | const _NI16_DIV: i16 = 1i16 / 0; + | ^^^^^^^^ attempt to divide `1_i16` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:213:28 + | +LL | const _NI16_DIV_P: &i16 = &(1i16 / 0); + | ^^^^^^^^^^ attempt to divide `1_i16` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:215:24 + | +LL | const _NI32_DIV: i32 = 1i32 / 0; + | ^^^^^^^^ attempt to divide `1_i32` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:216:28 + | +LL | const _NI32_DIV_P: &i32 = &(1i32 / 0); + | ^^^^^^^^^^ attempt to divide `1_i32` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:218:24 + | +LL | const _NI64_DIV: i64 = 1i64 / 0; + | ^^^^^^^^ attempt to divide `1_i64` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:219:28 + | +LL | const _NI64_DIV_P: &i64 = &(1i64 / 0); + | ^^^^^^^^^^ attempt to divide `1_i64` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:221:26 + | +LL | const _NI128_DIV: i128 = 1i128 / 0; + | ^^^^^^^^^ attempt to divide `1_i128` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:222:30 + | +LL | const _NI128_DIV_P: &i128 = &(1i128 / 0); + | ^^^^^^^^^^^ attempt to divide `1_i128` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:224:22 + | +LL | const _NU8_DIV: u8 = 1u8 / 0; + | ^^^^^^^ attempt to divide `1_u8` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:225:26 + | +LL | const _NU8_DIV_P: &u8 = &(1u8 / 0); + | ^^^^^^^^^ attempt to divide `1_u8` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:227:24 + | +LL | const _NU16_DIV: u16 = 1u16 / 0; + | ^^^^^^^^ attempt to divide `1_u16` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:228:28 + | +LL | const _NU16_DIV_P: &u16 = &(1u16 / 0); + | ^^^^^^^^^^ attempt to divide `1_u16` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:230:24 + | +LL | const _NU32_DIV: u32 = 1u32 / 0; + | ^^^^^^^^ attempt to divide `1_u32` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:231:28 + | +LL | const _NU32_DIV_P: &u32 = &(1u32 / 0); + | ^^^^^^^^^^ attempt to divide `1_u32` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:233:24 + | +LL | const _NU64_DIV: u64 = 1u64 / 0; + | ^^^^^^^^ attempt to divide `1_u64` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:234:28 + | +LL | const _NU64_DIV_P: &u64 = &(1u64 / 0); + | ^^^^^^^^^^ attempt to divide `1_u64` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:236:26 + | +LL | const _NU128_DIV: u128 = 1u128 / 0; + | ^^^^^^^^^ attempt to divide `1_u128` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:237:30 + | +LL | const _NU128_DIV_P: &u128 = &(1u128 / 0); + | ^^^^^^^^^^^ attempt to divide `1_u128` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:239:28 + | +LL | const _NISIZE_DIV: isize = 1isize / 0; + | ^^^^^^^^^^ attempt to divide `1_isize` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:240:32 + | +LL | const _NISIZE_DIV_P: &isize = &(1isize / 0); + | ^^^^^^^^^^^^ attempt to divide `1_isize` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:242:28 + | +LL | const _NUSIZE_DIV: usize = 1usize / 0; + | ^^^^^^^^^^ attempt to divide `1_usize` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:243:32 + | +LL | const _NUSIZE_DIV_P: &usize = &(1usize / 0); + | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:246:22 + | +LL | const _NI8_MOD: i8 = 1i8 % 0; + | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:247:26 + | +LL | const _NI8_MOD_P: &i8 = &(1i8 % 0); + | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:249:24 + | +LL | const _NI16_MOD: i16 = 1i16 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:250:28 + | +LL | const _NI16_MOD_P: &i16 = &(1i16 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:252:24 + | +LL | const _NI32_MOD: i32 = 1i32 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:253:28 + | +LL | const _NI32_MOD_P: &i32 = &(1i32 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:255:24 + | +LL | const _NI64_MOD: i64 = 1i64 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:256:28 + | +LL | const _NI64_MOD_P: &i64 = &(1i64 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:258:26 + | +LL | const _NI128_MOD: i128 = 1i128 % 0; + | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:259:30 + | +LL | const _NI128_MOD_P: &i128 = &(1i128 % 0); + | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:261:22 + | +LL | const _NU8_MOD: u8 = 1u8 % 0; + | ^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:262:26 + | +LL | const _NU8_MOD_P: &u8 = &(1u8 % 0); + | ^^^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:264:24 + | +LL | const _NU16_MOD: u16 = 1u16 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:265:28 + | +LL | const _NU16_MOD_P: &u16 = &(1u16 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:267:24 + | +LL | const _NU32_MOD: u32 = 1u32 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:268:28 + | +LL | const _NU32_MOD_P: &u32 = &(1u32 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:270:24 + | +LL | const _NU64_MOD: u64 = 1u64 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:271:28 + | +LL | const _NU64_MOD_P: &u64 = &(1u64 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:273:26 + | +LL | const _NU128_MOD: u128 = 1u128 % 0; + | ^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:274:30 + | +LL | const _NU128_MOD_P: &u128 = &(1u128 % 0); + | ^^^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:276:28 + | +LL | const _NISIZE_MOD: isize = 1isize % 0; + | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:277:32 + | +LL | const _NISIZE_MOD_P: &isize = &(1isize % 0); + | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:279:28 + | +LL | const _NUSIZE_MOD: usize = 1usize % 0; + | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:280:32 + | +LL | const _NUSIZE_MOD_P: &usize = &(1usize % 0); + | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:284:24 + | +LL | const _NI32_OOB: i32 = [1, 2, 3][4]; + | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + +error[E0080]: evaluation of constant value failed + --> $DIR/overflowing-consts.rs:285:28 + | +LL | const _NI32_OOB_P: &i32 = &([1, 2, 3][4]); + | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + +error: aborting due to 170 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/overflowing-consts.rs b/tests/ui/consts/overflowing-consts.rs new file mode 100644 index 0000000000000..52c0623f2c037 --- /dev/null +++ b/tests/ui/consts/overflowing-consts.rs @@ -0,0 +1,288 @@ +// Tests that overflowing or bound-exceeding operations +// for compile-time consts raise errors + +//@ revisions: noopt opt opt_with_overflow_checks +//@ [noopt]compile-flags: -C opt-level=0 +//@ [opt]compile-flags: -O +//@ [opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O +//@ ignore-pass (test tests codegen-time behaviour) +//@ normalize-stderr-test "shift left by `(64|32)_usize`, which" -> "shift left by `%BITS%`, which" +//@ normalize-stderr-test "shift right by `(64|32)_usize`, which" -> "shift right by `%BITS%`, which" + + +#[cfg(target_pointer_width = "32")] +const BITS: usize = 32; +#[cfg(target_pointer_width = "64")] +const BITS: usize = 64; + +// Shift left +const _NI8_SHL: i8 = 1i8 << 8; //~ ERROR: evaluation of constant value failed +const _NI8_SHL_P: &i8 = &(1i8 << 8); //~ ERROR: evaluation of constant value failed + +const _NI16_SHL: i16 = 1i16 << 16; //~ ERROR: evaluation of constant value failed +const _NI16_SHL_P: &i16 = &(1i16 << 16); //~ ERROR: evaluation of constant value failed + +const _NI32_SHL: i32 = 1i32 << 32; //~ ERROR: evaluation of constant value failed +const _NI32_SHL_P: &i32 = &(1i32 << 32); //~ ERROR: evaluation of constant value failed + +const _NI64_SHL: i64 = 1i64 << 64; //~ ERROR: evaluation of constant value failed +const _NI64_SHL_P: &i64 = &(1i64 << 64); //~ ERROR: evaluation of constant value failed + +const _NI128_SHL: i128 = 1i128 << 128; //~ ERROR: evaluation of constant value failed +const _NI128_SHL_P: &i128 = &(1i128 << 128); //~ ERROR: evaluation of constant value failed + +const _NU8_SHL: u8 = 1u8 << 8; //~ ERROR: evaluation of constant value failed +const _NU8_SHL_P: &u8 = &(1u8 << 8); //~ ERROR: evaluation of constant value failed + +const _NU16_SHL: u16 = 1u16 << 16; //~ ERROR: evaluation of constant value failed +const _NU16_SHL_P: &u16 = &(1u16 << 16); //~ ERROR: evaluation of constant value failed + +const _NU32_SHL: u32 = 1u32 << 32; //~ ERROR: evaluation of constant value failed +const _NU32_SHL_P: &u32 = &(1u32 << 32); //~ ERROR: evaluation of constant value failed + +const _NU64_SHL: u64 = 1u64 << 64; //~ ERROR: evaluation of constant value failed +const _NU64_SHL_P: &u64 = &(1u64 << 64); //~ ERROR: evaluation of constant value failed + +const _NU128_SHL: u128 = 1u128 << 128; //~ ERROR: evaluation of constant value failed +const _NU128_SHL_P: &u128 = &(1u128 << 128); //~ ERROR: evaluation of constant value failed + +const _NISIZE_SHL: isize = 1isize << BITS; //~ ERROR: evaluation of constant value failed +const _NISIZE_SHL_P: &isize = &(1isize << BITS); //~ ERROR: evaluation of constant value failed + +const _NUSIZE_SHL: usize = 1usize << BITS; //~ ERROR: evaluation of constant value failed +const _NUSIZE_SHL_P: &usize = &(1usize << BITS); //~ ERROR: evaluation of constant value failed + + +// Shift right +const _NI8_SHR: i8 = 1i8 >> 8; //~ ERROR: evaluation of constant value failed +const _NI8_SHR_P: &i8 = &(1i8 >> 8); //~ ERROR: evaluation of constant value failed + +const _NI16_SHR: i16 = 1i16 >> 16; //~ ERROR: evaluation of constant value failed +const _NI16_SHR_P: &i16 = &(1i16 >> 16); //~ ERROR: evaluation of constant value failed + +const _NI32_SHR: i32 = 1i32 >> 32; //~ ERROR: evaluation of constant value failed +const _NI32_SHR_P: &i32 = &(1i32 >> 32); //~ ERROR: evaluation of constant value failed + +const _NI64_SHR: i64 = 1i64 >> 64; //~ ERROR: evaluation of constant value failed +const _NI64_SHR_P: &i64 = &(1i64 >> 64); //~ ERROR: evaluation of constant value failed + +const _NI128_SHR: i128 = 1i128 >> 128; //~ ERROR: evaluation of constant value failed +const _NI128_SHR_P: &i128 = &(1i128 >> 128); //~ ERROR: evaluation of constant value failed + +const _NU8_SHR: u8 = 1u8 >> 8; //~ ERROR: evaluation of constant value failed +const _NU8_SHR_P: &u8 = &(1u8 >> 8); //~ ERROR: evaluation of constant value failed + +const _NU16_SHR: u16 = 1u16 >> 16; //~ ERROR: evaluation of constant value failed +const _NU16_SHR_P: &u16 = &(1u16 >> 16); //~ ERROR: evaluation of constant value failed + +const _NU32_SHR: u32 = 1u32 >> 32; //~ ERROR: evaluation of constant value failed +const _NU32_SHR_P: &u32 = &(1u32 >> 32); //~ ERROR: evaluation of constant value failed + +const _NU64_SHR: u64 = 1u64 >> 64; //~ ERROR: evaluation of constant value failed +const _NU64_SHR_P: &u64 = &(1u64 >> 64); //~ ERROR: evaluation of constant value failed + +const _NU128_SHR: u128 = 1u128 >> 128; //~ ERROR: evaluation of constant value failed +const _NU128_SHR_P: &u128 = &(1u128 >> 128); //~ ERROR: evaluation of constant value failed + +const _NISIZE_SHR: isize = 1isize >> BITS; //~ ERROR: evaluation of constant value failed +const _NISIZE_SHR_P: &isize = &(1isize >> BITS); //~ ERROR: evaluation of constant value failed + +const _NUSIZE_SHR: usize = 1usize >> BITS; //~ ERROR: evaluation of constant value failed +const _NUSIZE_SHR_P: &usize = &(1usize >> BITS); //~ ERROR: evaluation of constant value failed + + +// Addition +const _NI8_ADD: i8 = 1i8 + i8::MAX; //~ ERROR: evaluation of constant value failed +const _NI8_ADD_P: &i8 = &(1i8 + i8::MAX); //~ ERROR: evaluation of constant value failed + +const _NI16_ADD: i16 = 1i16 + i16::MAX; //~ ERROR: evaluation of constant value failed +const _NI16_ADD_P: &i16 = &(1i16 + i16::MAX); //~ ERROR: evaluation of constant value failed + +const _NI32_ADD: i32 = 1i32 + i32::MAX; //~ ERROR: evaluation of constant value failed +const _NI32_ADD_P: &i32 = &(1i32 + i32::MAX); //~ ERROR: evaluation of constant value failed + +const _NI64_ADD: i64 = 1i64 + i64::MAX; //~ ERROR: evaluation of constant value failed +const _NI64_ADD_P: &i64 = &(1i64 + i64::MAX); //~ ERROR: evaluation of constant value failed + +const _NI128_ADD: i128 = 1i128 + i128::MAX; //~ ERROR: evaluation of constant value failed +const _NI128_ADD_P: &i128 = &(1i128 + i128::MAX); //~ ERROR: evaluation of constant value failed + +const _NU8_ADD: u8 = 1u8 + u8::MAX; //~ ERROR: evaluation of constant value failed +const _NU8_ADD_P: &u8 = &(1u8 + u8::MAX); //~ ERROR: evaluation of constant value failed + +const _NU16_ADD: u16 = 1u16 + u16::MAX; //~ ERROR: evaluation of constant value failed +const _NU16_ADD_P: &u16 = &(1u16 + u16::MAX); //~ ERROR: evaluation of constant value failed + +const _NU32_ADD: u32 = 1u32 + u32::MAX; //~ ERROR: evaluation of constant value failed +const _NU32_ADD_P: &u32 = &(1u32 + u32::MAX); //~ ERROR: evaluation of constant value failed + +const _NU64_ADD: u64 = 1u64 + u64::MAX; //~ ERROR: evaluation of constant value failed +const _NU64_ADD_P: &u64 = &(1u64 + u64::MAX); //~ ERROR: evaluation of constant value failed + +const _NU128_ADD: u128 = 1u128 + u128::MAX; //~ ERROR: evaluation of constant value failed +const _NU128_ADD_P: &u128 = &(1u128 + u128::MAX); //~ ERROR: evaluation of constant value failed + +const _NISIZE_ADD: isize = 1isize + isize::MAX; //~ ERROR: evaluation of constant value failed +const _NISIZE_ADD_P: &isize = &(1isize + isize::MAX); //~ ERROR: evaluation of constant value failed + +const _NUSIZE_ADD: usize = 1usize + usize::MAX; //~ ERROR: evaluation of constant value failed +const _NUSIZE_ADD_P: &usize = &(1usize + usize::MAX); //~ ERROR: evaluation of constant value failed + + +// Subtraction +const _NI8_SUB: i8 = -5i8 - i8::MAX; //~ ERROR: evaluation of constant value failed +const _NI8_SUB_P: &i8 = &(-5i8 - i8::MAX); //~ ERROR: evaluation of constant value failed + +const _NI16_SUB: i16 = -5i16 - i16::MAX; //~ ERROR: evaluation of constant value failed +const _NI16_SUB_P: &i16 = &(-5i16 - i16::MAX); //~ ERROR: evaluation of constant value failed + +const _NI32_SUB: i32 = -5i32 - i32::MAX; //~ ERROR: evaluation of constant value failed +const _NI32_SUB_P: &i32 = &(-5i32 - i32::MAX); //~ ERROR: evaluation of constant value failed + +const _NI64_SUB: i64 = -5i64 - i64::MAX; //~ ERROR: evaluation of constant value failed +const _NI64_SUB_P: &i64 = &(-5i64 - i64::MAX); //~ ERROR: evaluation of constant value failed + +const _NI128_SUB: i128 = -5i128 - i128::MAX; //~ ERROR: evaluation of constant value failed +const _NI128_SUB_P: &i128 = &(-5i128 - i128::MAX); //~ ERROR: evaluation of constant value failed + +const _NU8_SUB: u8 = 1u8 - 5; //~ ERROR: evaluation of constant value failed +const _NU8_SUB_P: &u8 = &(1u8 - 5); //~ ERROR: evaluation of constant value failed + +const _NU16_SUB: u16 = 1u16 - 5; //~ ERROR: evaluation of constant value failed +const _NU16_SUB_P: &u16 = &(1u16 - 5); //~ ERROR: evaluation of constant value failed + +const _NU32_SUB: u32 = 1u32 - 5; //~ ERROR: evaluation of constant value failed +const _NU32_SUB_P: &u32 = &(1u32 - 5); //~ ERROR: evaluation of constant value failed + +const _NU64_SUB: u64 = 1u64 - 5; //~ ERROR: evaluation of constant value failed +const _NU64_SUB_P: &u64 = &(1u64 - 5); //~ ERROR: evaluation of constant value failed + +const _NU128_SUB: u128 = 1u128 - 5; //~ ERROR: evaluation of constant value failed +const _NU128_SUB_P: &u128 = &(1u128 - 5); //~ ERROR: evaluation of constant value failed + +const _NISIZE_SUB: isize = -5isize - isize::MAX; //~ ERROR: evaluation of constant value failed +const _NISIZE_SUB_P: &isize = &(-5isize - isize::MAX); //~ ERROR: evaluation of constant value failed + +const _NUSIZE_SUB: usize = 1usize - 5 ; //~ ERROR: evaluation of constant value failed +const _NUSIZE_SUB_P: &usize = &(1usize - 5 ); //~ ERROR: evaluation of constant value failed + + +// Multiplication +const _NI8_MUL: i8 = i8::MAX * 5; //~ ERROR: evaluation of constant value failed +const _NI8_MUL_P: &i8 = &(i8::MAX * 5); //~ ERROR: evaluation of constant value failed + +const _NI16_MUL: i16 = i16::MAX * 5; //~ ERROR: evaluation of constant value failed +const _NI16_MUL_P: &i16 = &(i16::MAX * 5); //~ ERROR: evaluation of constant value failed + +const _NI32_MUL: i32 = i32::MAX * 5; //~ ERROR: evaluation of constant value failed +const _NI32_MUL_P: &i32 = &(i32::MAX * 5); //~ ERROR: evaluation of constant value failed + +const _NI64_MUL: i64 = i64::MAX * 5; //~ ERROR: evaluation of constant value failed +const _NI64_MUL_P: &i64 = &(i64::MAX * 5); //~ ERROR: evaluation of constant value failed + +const _NI128_MUL: i128 = i128::MAX * 5; //~ ERROR: evaluation of constant value failed +const _NI128_MUL_P: &i128 = &(i128::MAX * 5); //~ ERROR: evaluation of constant value failed + +const _NU8_MUL: u8 = u8::MAX * 5; //~ ERROR: evaluation of constant value failed +const _NU8_MUL_P: &u8 = &(u8::MAX * 5); //~ ERROR: evaluation of constant value failed + +const _NU16_MUL: u16 = u16::MAX * 5; //~ ERROR: evaluation of constant value failed +const _NU16_MUL_P: &u16 = &(u16::MAX * 5); //~ ERROR: evaluation of constant value failed + +const _NU32_MUL: u32 = u32::MAX * 5; //~ ERROR: evaluation of constant value failed +const _NU32_MUL_P: &u32 = &(u32::MAX * 5); //~ ERROR: evaluation of constant value failed + +const _NU64_MUL: u64 = u64::MAX * 5; //~ ERROR: evaluation of constant value failed +const _NU64_MUL_P: &u64 = &(u64::MAX * 5); //~ ERROR: evaluation of constant value failed + +const _NU128_MUL: u128 = u128::MAX * 5; //~ ERROR: evaluation of constant value failed +const _NU128_MUL_P: &u128 = &(u128::MAX * 5); //~ ERROR: evaluation of constant value failed + +const _NISIZE_MUL: isize = isize::MAX * 5; //~ ERROR: evaluation of constant value failed +const _NISIZE_MUL_P: &isize = &(isize::MAX * 5); //~ ERROR: evaluation of constant value failed + +const _NUSIZE_MUL: usize = usize::MAX * 5; //~ ERROR: evaluation of constant value failed +const _NUSIZE_MUL_P: &usize = &(usize::MAX * 5); //~ ERROR: evaluation of constant value failed + + +// Division +const _NI8_DIV: i8 = 1i8 / 0; //~ ERROR: evaluation of constant value failed +const _NI8_DIV_P: &i8 = &(1i8 / 0); //~ ERROR: evaluation of constant value failed + +const _NI16_DIV: i16 = 1i16 / 0; //~ ERROR: evaluation of constant value failed +const _NI16_DIV_P: &i16 = &(1i16 / 0); //~ ERROR: evaluation of constant value failed + +const _NI32_DIV: i32 = 1i32 / 0; //~ ERROR: evaluation of constant value failed +const _NI32_DIV_P: &i32 = &(1i32 / 0); //~ ERROR: evaluation of constant value failed + +const _NI64_DIV: i64 = 1i64 / 0; //~ ERROR: evaluation of constant value failed +const _NI64_DIV_P: &i64 = &(1i64 / 0); //~ ERROR: evaluation of constant value failed + +const _NI128_DIV: i128 = 1i128 / 0; //~ ERROR: evaluation of constant value failed +const _NI128_DIV_P: &i128 = &(1i128 / 0); //~ ERROR: evaluation of constant value failed + +const _NU8_DIV: u8 = 1u8 / 0; //~ ERROR: evaluation of constant value failed +const _NU8_DIV_P: &u8 = &(1u8 / 0); //~ ERROR: evaluation of constant value failed + +const _NU16_DIV: u16 = 1u16 / 0; //~ ERROR: evaluation of constant value failed +const _NU16_DIV_P: &u16 = &(1u16 / 0); //~ ERROR: evaluation of constant value failed + +const _NU32_DIV: u32 = 1u32 / 0; //~ ERROR: evaluation of constant value failed +const _NU32_DIV_P: &u32 = &(1u32 / 0); //~ ERROR: evaluation of constant value failed + +const _NU64_DIV: u64 = 1u64 / 0; //~ ERROR: evaluation of constant value failed +const _NU64_DIV_P: &u64 = &(1u64 / 0); //~ ERROR: evaluation of constant value failed + +const _NU128_DIV: u128 = 1u128 / 0; //~ ERROR: evaluation of constant value failed +const _NU128_DIV_P: &u128 = &(1u128 / 0); //~ ERROR: evaluation of constant value failed + +const _NISIZE_DIV: isize = 1isize / 0; //~ ERROR: evaluation of constant value failed +const _NISIZE_DIV_P: &isize = &(1isize / 0); //~ ERROR: evaluation of constant value failed + +const _NUSIZE_DIV: usize = 1usize / 0; //~ ERROR: evaluation of constant value failed +const _NUSIZE_DIV_P: &usize = &(1usize / 0); //~ ERROR: evaluation of constant value failed + +// Modulus +const _NI8_MOD: i8 = 1i8 % 0; //~ ERROR: evaluation of constant value failed +const _NI8_MOD_P: &i8 = &(1i8 % 0); //~ ERROR: evaluation of constant value failed + +const _NI16_MOD: i16 = 1i16 % 0; //~ ERROR: evaluation of constant value failed +const _NI16_MOD_P: &i16 = &(1i16 % 0); //~ ERROR: evaluation of constant value failed + +const _NI32_MOD: i32 = 1i32 % 0; //~ ERROR: evaluation of constant value failed +const _NI32_MOD_P: &i32 = &(1i32 % 0); //~ ERROR: evaluation of constant value failed + +const _NI64_MOD: i64 = 1i64 % 0; //~ ERROR: evaluation of constant value failed +const _NI64_MOD_P: &i64 = &(1i64 % 0); //~ ERROR: evaluation of constant value failed + +const _NI128_MOD: i128 = 1i128 % 0; //~ ERROR: evaluation of constant value failed +const _NI128_MOD_P: &i128 = &(1i128 % 0); //~ ERROR: evaluation of constant value failed + +const _NU8_MOD: u8 = 1u8 % 0; //~ ERROR: evaluation of constant value failed +const _NU8_MOD_P: &u8 = &(1u8 % 0); //~ ERROR: evaluation of constant value failed + +const _NU16_MOD: u16 = 1u16 % 0; //~ ERROR: evaluation of constant value failed +const _NU16_MOD_P: &u16 = &(1u16 % 0); //~ ERROR: evaluation of constant value failed + +const _NU32_MOD: u32 = 1u32 % 0; //~ ERROR: evaluation of constant value failed +const _NU32_MOD_P: &u32 = &(1u32 % 0); //~ ERROR: evaluation of constant value failed + +const _NU64_MOD: u64 = 1u64 % 0; //~ ERROR: evaluation of constant value failed +const _NU64_MOD_P: &u64 = &(1u64 % 0); //~ ERROR: evaluation of constant value failed + +const _NU128_MOD: u128 = 1u128 % 0; //~ ERROR: evaluation of constant value failed +const _NU128_MOD_P: &u128 = &(1u128 % 0); //~ ERROR: evaluation of constant value failed + +const _NISIZE_MOD: isize = 1isize % 0; //~ ERROR: evaluation of constant value failed +const _NISIZE_MOD_P: &isize = &(1isize % 0); //~ ERROR: evaluation of constant value failed + +const _NUSIZE_MOD: usize = 1usize % 0; //~ ERROR: evaluation of constant value failed +const _NUSIZE_MOD_P: &usize = &(1usize % 0); //~ ERROR: evaluation of constant value failed + + +// Out of bounds access +const _NI32_OOB: i32 = [1, 2, 3][4]; //~ ERROR: evaluation of constant value failed +const _NI32_OOB_P: &i32 = &([1, 2, 3][4]); //~ ERROR: evaluation of constant value failed + + +pub fn main() {} diff --git a/tests/ui/consts/promotion.rs b/tests/ui/consts/promotion.rs index 783ca47d2c62e..211dcf8a4e8f2 100644 --- a/tests/ui/consts/promotion.rs +++ b/tests/ui/consts/promotion.rs @@ -25,9 +25,8 @@ fn main() { assert_static(&["d", "e", "f"]); assert_eq!(C, 42); - // make sure that these do not cause trouble despite overflowing + // make sure that this does not cause trouble despite overflowing assert_static(&(0-1)); - assert_static(&-i32::MIN); // div-by-non-0 is okay assert_static(&(1/1)); diff --git a/tests/ui/lint/issue-117949.noopt.stderr b/tests/ui/lint/issue-117949.noopt.stderr new file mode 100644 index 0000000000000..607488e2a4af8 --- /dev/null +++ b/tests/ui/lint/issue-117949.noopt.stderr @@ -0,0 +1,54 @@ +error: this arithmetic operation will overflow + --> $DIR/issue-117949.rs:16:24 + | +LL | format_args!("{}", 5 * i32::MAX); + | ^^^^^^^^^^^^ attempt to compute `5_i32 * i32::MAX`, which would overflow + | + = note: `#[deny(arithmetic_overflow)]` on by default + +error: this arithmetic operation will overflow + --> $DIR/issue-117949.rs:15:24 + | +LL | format_args!("{}", -5 - i32::MAX); + | ^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-117949.rs:14:24 + | +LL | format_args!("{}", 1 + i32::MAX); + | ^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-117949.rs:13:24 + | +LL | format_args!("{}", 1 >> 32); + | ^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-117949.rs:12:24 + | +LL | format_args!("{}", 1 << 32); + | ^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error: this operation will panic at runtime + --> $DIR/issue-117949.rs:17:24 + | +LL | format_args!("{}", 1 / 0); + | ^^^^^ attempt to divide `1_i32` by zero + | + = note: `#[deny(unconditional_panic)]` on by default + +error: this operation will panic at runtime + --> $DIR/issue-117949.rs:18:24 + | +LL | format_args!("{}", 1 % 0); + | ^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/issue-117949.rs:19:24 + | +LL | format_args!("{}", [1, 2, 3][4]); + | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + +error: aborting due to 8 previous errors + diff --git a/tests/ui/lint/issue-117949.opt.stderr b/tests/ui/lint/issue-117949.opt.stderr new file mode 100644 index 0000000000000..607488e2a4af8 --- /dev/null +++ b/tests/ui/lint/issue-117949.opt.stderr @@ -0,0 +1,54 @@ +error: this arithmetic operation will overflow + --> $DIR/issue-117949.rs:16:24 + | +LL | format_args!("{}", 5 * i32::MAX); + | ^^^^^^^^^^^^ attempt to compute `5_i32 * i32::MAX`, which would overflow + | + = note: `#[deny(arithmetic_overflow)]` on by default + +error: this arithmetic operation will overflow + --> $DIR/issue-117949.rs:15:24 + | +LL | format_args!("{}", -5 - i32::MAX); + | ^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-117949.rs:14:24 + | +LL | format_args!("{}", 1 + i32::MAX); + | ^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-117949.rs:13:24 + | +LL | format_args!("{}", 1 >> 32); + | ^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-117949.rs:12:24 + | +LL | format_args!("{}", 1 << 32); + | ^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error: this operation will panic at runtime + --> $DIR/issue-117949.rs:17:24 + | +LL | format_args!("{}", 1 / 0); + | ^^^^^ attempt to divide `1_i32` by zero + | + = note: `#[deny(unconditional_panic)]` on by default + +error: this operation will panic at runtime + --> $DIR/issue-117949.rs:18:24 + | +LL | format_args!("{}", 1 % 0); + | ^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/issue-117949.rs:19:24 + | +LL | format_args!("{}", [1, 2, 3][4]); + | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + +error: aborting due to 8 previous errors + diff --git a/tests/ui/lint/issue-117949.opt_with_overflow_checks.stderr b/tests/ui/lint/issue-117949.opt_with_overflow_checks.stderr new file mode 100644 index 0000000000000..607488e2a4af8 --- /dev/null +++ b/tests/ui/lint/issue-117949.opt_with_overflow_checks.stderr @@ -0,0 +1,54 @@ +error: this arithmetic operation will overflow + --> $DIR/issue-117949.rs:16:24 + | +LL | format_args!("{}", 5 * i32::MAX); + | ^^^^^^^^^^^^ attempt to compute `5_i32 * i32::MAX`, which would overflow + | + = note: `#[deny(arithmetic_overflow)]` on by default + +error: this arithmetic operation will overflow + --> $DIR/issue-117949.rs:15:24 + | +LL | format_args!("{}", -5 - i32::MAX); + | ^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-117949.rs:14:24 + | +LL | format_args!("{}", 1 + i32::MAX); + | ^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-117949.rs:13:24 + | +LL | format_args!("{}", 1 >> 32); + | ^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-117949.rs:12:24 + | +LL | format_args!("{}", 1 << 32); + | ^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error: this operation will panic at runtime + --> $DIR/issue-117949.rs:17:24 + | +LL | format_args!("{}", 1 / 0); + | ^^^^^ attempt to divide `1_i32` by zero + | + = note: `#[deny(unconditional_panic)]` on by default + +error: this operation will panic at runtime + --> $DIR/issue-117949.rs:18:24 + | +LL | format_args!("{}", 1 % 0); + | ^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/issue-117949.rs:19:24 + | +LL | format_args!("{}", [1, 2, 3][4]); + | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + +error: aborting due to 8 previous errors + diff --git a/tests/ui/lint/issue-117949.rs b/tests/ui/lint/issue-117949.rs new file mode 100644 index 0000000000000..5673227f35d39 --- /dev/null +++ b/tests/ui/lint/issue-117949.rs @@ -0,0 +1,20 @@ +// Regression test for issue #117949 + +//@ revisions: noopt opt opt_with_overflow_checks +//@ [noopt]compile-flags: -C opt-level=0 -Z deduplicate-diagnostics=yes +//@ [opt]compile-flags: -O +//@ [opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O -Z deduplicate-diagnostics=yes +//@ build-fail +//@ ignore-pass (test tests codegen-time behaviour) + + +fn main() { + format_args!("{}", 1 << 32); //~ ERROR: arithmetic operation will overflow + format_args!("{}", 1 >> 32); //~ ERROR: arithmetic operation will overflow + format_args!("{}", 1 + i32::MAX); //~ ERROR: arithmetic operation will overflow + format_args!("{}", -5 - i32::MAX); //~ ERROR: arithmetic operation will overflow + format_args!("{}", 5 * i32::MAX); //~ ERROR: arithmetic operation will overflow + format_args!("{}", 1 / 0); //~ ERROR: this operation will panic at runtime + format_args!("{}", 1 % 0); //~ ERROR: this operation will panic at runtime + format_args!("{}", [1, 2, 3][4]); //~ ERROR: this operation will panic at runtime +} diff --git a/tests/ui/lint/lint-exceeding-bitshifts.noopt.stderr b/tests/ui/lint/lint-exceeding-bitshifts.noopt.stderr deleted file mode 100644 index 3a84c6c1fb1f9..0000000000000 --- a/tests/ui/lint/lint-exceeding-bitshifts.noopt.stderr +++ /dev/null @@ -1,152 +0,0 @@ -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:18:20 - | -LL | const N: i32 = T::N << 42; - | ^^^^^^^^^^ attempt to shift left by `42_i32`, which would overflow - | -note: the lint level is defined here - --> $DIR/lint-exceeding-bitshifts.rs:10:9 - | -LL | #![warn(arithmetic_overflow)] - | ^^^^^^^^^^^^^^^^^^^ - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:22:13 - | -LL | let _ = x << 42; - | ^^^^^^^ attempt to shift left by `42_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:27:15 - | -LL | let n = 1u8 << 8; - | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:29:15 - | -LL | let n = 1u16 << 16; - | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:31:15 - | -LL | let n = 1u32 << 32; - | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:33:15 - | -LL | let n = 1u64 << 64; - | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:35:15 - | -LL | let n = 1i8 << 8; - | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:37:15 - | -LL | let n = 1i16 << 16; - | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:39:15 - | -LL | let n = 1i32 << 32; - | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:41:15 - | -LL | let n = 1i64 << 64; - | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:44:15 - | -LL | let n = 1u8 >> 8; - | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:46:15 - | -LL | let n = 1u16 >> 16; - | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:48:15 - | -LL | let n = 1u32 >> 32; - | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:50:15 - | -LL | let n = 1u64 >> 64; - | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:52:15 - | -LL | let n = 1i8 >> 8; - | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:54:15 - | -LL | let n = 1i16 >> 16; - | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:56:15 - | -LL | let n = 1i32 >> 32; - | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:58:15 - | -LL | let n = 1i64 >> 64; - | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:62:15 - | -LL | let n = n << 8; - | ^^^^^^ attempt to shift left by `8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:64:15 - | -LL | let n = 1u8 << -8; - | ^^^^^^^^^ attempt to shift left by `-8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:69:15 - | -LL | let n = 1u8 << (4+4); - | ^^^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:71:15 - | -LL | let n = 1i64 >> [64][0]; - | ^^^^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:77:15 - | -LL | let n = 1_isize << BITS; - | ^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:78:15 - | -LL | let n = 1_usize << BITS; - | ^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow - -warning: 24 warnings emitted - diff --git a/tests/ui/lint/lint-exceeding-bitshifts.opt.stderr b/tests/ui/lint/lint-exceeding-bitshifts.opt.stderr deleted file mode 100644 index 3a84c6c1fb1f9..0000000000000 --- a/tests/ui/lint/lint-exceeding-bitshifts.opt.stderr +++ /dev/null @@ -1,152 +0,0 @@ -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:18:20 - | -LL | const N: i32 = T::N << 42; - | ^^^^^^^^^^ attempt to shift left by `42_i32`, which would overflow - | -note: the lint level is defined here - --> $DIR/lint-exceeding-bitshifts.rs:10:9 - | -LL | #![warn(arithmetic_overflow)] - | ^^^^^^^^^^^^^^^^^^^ - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:22:13 - | -LL | let _ = x << 42; - | ^^^^^^^ attempt to shift left by `42_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:27:15 - | -LL | let n = 1u8 << 8; - | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:29:15 - | -LL | let n = 1u16 << 16; - | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:31:15 - | -LL | let n = 1u32 << 32; - | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:33:15 - | -LL | let n = 1u64 << 64; - | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:35:15 - | -LL | let n = 1i8 << 8; - | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:37:15 - | -LL | let n = 1i16 << 16; - | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:39:15 - | -LL | let n = 1i32 << 32; - | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:41:15 - | -LL | let n = 1i64 << 64; - | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:44:15 - | -LL | let n = 1u8 >> 8; - | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:46:15 - | -LL | let n = 1u16 >> 16; - | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:48:15 - | -LL | let n = 1u32 >> 32; - | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:50:15 - | -LL | let n = 1u64 >> 64; - | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:52:15 - | -LL | let n = 1i8 >> 8; - | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:54:15 - | -LL | let n = 1i16 >> 16; - | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:56:15 - | -LL | let n = 1i32 >> 32; - | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:58:15 - | -LL | let n = 1i64 >> 64; - | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:62:15 - | -LL | let n = n << 8; - | ^^^^^^ attempt to shift left by `8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:64:15 - | -LL | let n = 1u8 << -8; - | ^^^^^^^^^ attempt to shift left by `-8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:69:15 - | -LL | let n = 1u8 << (4+4); - | ^^^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:71:15 - | -LL | let n = 1i64 >> [64][0]; - | ^^^^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:77:15 - | -LL | let n = 1_isize << BITS; - | ^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:78:15 - | -LL | let n = 1_usize << BITS; - | ^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow - -warning: 24 warnings emitted - diff --git a/tests/ui/lint/lint-exceeding-bitshifts.opt_with_overflow_checks.stderr b/tests/ui/lint/lint-exceeding-bitshifts.opt_with_overflow_checks.stderr deleted file mode 100644 index 3a84c6c1fb1f9..0000000000000 --- a/tests/ui/lint/lint-exceeding-bitshifts.opt_with_overflow_checks.stderr +++ /dev/null @@ -1,152 +0,0 @@ -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:18:20 - | -LL | const N: i32 = T::N << 42; - | ^^^^^^^^^^ attempt to shift left by `42_i32`, which would overflow - | -note: the lint level is defined here - --> $DIR/lint-exceeding-bitshifts.rs:10:9 - | -LL | #![warn(arithmetic_overflow)] - | ^^^^^^^^^^^^^^^^^^^ - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:22:13 - | -LL | let _ = x << 42; - | ^^^^^^^ attempt to shift left by `42_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:27:15 - | -LL | let n = 1u8 << 8; - | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:29:15 - | -LL | let n = 1u16 << 16; - | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:31:15 - | -LL | let n = 1u32 << 32; - | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:33:15 - | -LL | let n = 1u64 << 64; - | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:35:15 - | -LL | let n = 1i8 << 8; - | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:37:15 - | -LL | let n = 1i16 << 16; - | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:39:15 - | -LL | let n = 1i32 << 32; - | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:41:15 - | -LL | let n = 1i64 << 64; - | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:44:15 - | -LL | let n = 1u8 >> 8; - | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:46:15 - | -LL | let n = 1u16 >> 16; - | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:48:15 - | -LL | let n = 1u32 >> 32; - | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:50:15 - | -LL | let n = 1u64 >> 64; - | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:52:15 - | -LL | let n = 1i8 >> 8; - | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:54:15 - | -LL | let n = 1i16 >> 16; - | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:56:15 - | -LL | let n = 1i32 >> 32; - | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:58:15 - | -LL | let n = 1i64 >> 64; - | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:62:15 - | -LL | let n = n << 8; - | ^^^^^^ attempt to shift left by `8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:64:15 - | -LL | let n = 1u8 << -8; - | ^^^^^^^^^ attempt to shift left by `-8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:69:15 - | -LL | let n = 1u8 << (4+4); - | ^^^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:71:15 - | -LL | let n = 1i64 >> [64][0]; - | ^^^^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:77:15 - | -LL | let n = 1_isize << BITS; - | ^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow - -warning: this arithmetic operation will overflow - --> $DIR/lint-exceeding-bitshifts.rs:78:15 - | -LL | let n = 1_usize << BITS; - | ^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow - -warning: 24 warnings emitted - diff --git a/tests/ui/lint/lint-exceeding-bitshifts.rs b/tests/ui/lint/lint-exceeding-bitshifts.rs deleted file mode 100644 index ea9d5ce6781fb..0000000000000 --- a/tests/ui/lint/lint-exceeding-bitshifts.rs +++ /dev/null @@ -1,79 +0,0 @@ -//@ revisions: noopt opt opt_with_overflow_checks -//@[noopt]compile-flags: -C opt-level=0 -//@[opt]compile-flags: -O -//@[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O -//@ build-pass -//@ ignore-pass (test emits codegen-time warnings and verifies that they are not errors) -//@ normalize-stderr-test "shift left by `(64|32)_usize`, which" -> "shift left by `%BITS%`, which" - -#![crate_type="lib"] -#![warn(arithmetic_overflow)] - - -pub trait Foo { - const N: i32; -} - -impl Foo for Vec { - const N: i32 = T::N << 42; //~ WARN: arithmetic operation will overflow -} - -pub fn foo(x: i32) { - let _ = x << 42; //~ WARN: arithmetic operation will overflow -} - -pub fn main() { - let n = 1u8 << 7; - let n = 1u8 << 8; //~ WARN: arithmetic operation will overflow - let n = 1u16 << 15; - let n = 1u16 << 16; //~ WARN: arithmetic operation will overflow - let n = 1u32 << 31; - let n = 1u32 << 32; //~ WARN: arithmetic operation will overflow - let n = 1u64 << 63; - let n = 1u64 << 64; //~ WARN: arithmetic operation will overflow - let n = 1i8 << 7; - let n = 1i8 << 8; //~ WARN: arithmetic operation will overflow - let n = 1i16 << 15; - let n = 1i16 << 16; //~ WARN: arithmetic operation will overflow - let n = 1i32 << 31; - let n = 1i32 << 32; //~ WARN: arithmetic operation will overflow - let n = 1i64 << 63; - let n = 1i64 << 64; //~ WARN: arithmetic operation will overflow - - let n = 1u8 >> 7; - let n = 1u8 >> 8; //~ WARN: arithmetic operation will overflow - let n = 1u16 >> 15; - let n = 1u16 >> 16; //~ WARN: arithmetic operation will overflow - let n = 1u32 >> 31; - let n = 1u32 >> 32; //~ WARN: arithmetic operation will overflow - let n = 1u64 >> 63; - let n = 1u64 >> 64; //~ WARN: arithmetic operation will overflow - let n = 1i8 >> 7; - let n = 1i8 >> 8; //~ WARN: arithmetic operation will overflow - let n = 1i16 >> 15; - let n = 1i16 >> 16; //~ WARN: arithmetic operation will overflow - let n = 1i32 >> 31; - let n = 1i32 >> 32; //~ WARN: arithmetic operation will overflow - let n = 1i64 >> 63; - let n = 1i64 >> 64; //~ WARN: arithmetic operation will overflow - - let n = 1u8; - let n = n << 7; - let n = n << 8; //~ WARN: arithmetic operation will overflow - - let n = 1u8 << -8; //~ WARN: arithmetic operation will overflow - - let n = 1i8<<(1isize+-1); - - let n = 1u8 << (4+3); - let n = 1u8 << (4+4); //~ WARN: arithmetic operation will overflow - let n = 1i64 >> [63][0]; - let n = 1i64 >> [64][0]; //~ WARN: arithmetic operation will overflow - - #[cfg(target_pointer_width = "32")] - const BITS: usize = 32; - #[cfg(target_pointer_width = "64")] - const BITS: usize = 64; - let n = 1_isize << BITS; //~ WARN: arithmetic operation will overflow - let n = 1_usize << BITS; //~ WARN: arithmetic operation will overflow -} diff --git a/tests/ui/lint/lint-overflowing-ops.noopt.stderr b/tests/ui/lint/lint-overflowing-ops.noopt.stderr new file mode 100644 index 0000000000000..93fc19ce79e44 --- /dev/null +++ b/tests/ui/lint/lint-overflowing-ops.noopt.stderr @@ -0,0 +1,1030 @@ +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:26:14 + | +LL | let _n = 1u8 << 8; + | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | +note: the lint level is defined here + --> $DIR/lint-overflowing-ops.rs:17:9 + | +LL | #![deny(arithmetic_overflow)] + | ^^^^^^^^^^^^^^^^^^^ + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:212:15 + | +LL | let _n = &(usize::MAX * 5); + | ^^^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:209:15 + | +LL | let _n = &(isize::MAX * 5); + | ^^^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:206:15 + | +LL | let _n = &(i128::MAX * 5); + | ^^^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:203:15 + | +LL | let _n = &(i64::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:200:15 + | +LL | let _n = &(i32::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:197:15 + | +LL | let _n = &(i16::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:194:15 + | +LL | let _n = &(i8::MAX * i8::MAX); + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `i8::MAX * i8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:191:15 + | +LL | let _n = &(u128::MAX * 5); + | ^^^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:188:15 + | +LL | let _n = &(u64::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:185:15 + | +LL | let _n = &(u32::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:182:15 + | +LL | let _n = &(u16::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:179:15 + | +LL | let _n = &(u8::MAX * 5); + | ^^^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:174:15 + | +LL | let _n = &(1usize - 5); + | ^^^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:171:15 + | +LL | let _n = &(-5isize - isize::MAX); + | ^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:168:15 + | +LL | let _n = &(-5i128 - i128::MAX); + | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:165:15 + | +LL | let _n = &(-5i64 - i64::MAX); + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:162:15 + | +LL | let _n = &(-5i32 - i32::MAX); + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:159:15 + | +LL | let _n = &(-5i16 - i16::MAX); + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:156:15 + | +LL | let _n = &(-5i8 - i8::MAX); + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:153:15 + | +LL | let _n = &(1u128 - 5); + | ^^^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:150:15 + | +LL | let _n = &(1u64 - 5); + | ^^^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:147:15 + | +LL | let _n = &(1u32 - 5); + | ^^^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:144:15 + | +LL | let _n = &(1u16 - 5); + | ^^^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:141:15 + | +LL | let _n = &(1u8 - 5); + | ^^^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:136:15 + | +LL | let _n = &(1usize + usize::MAX); + | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:133:15 + | +LL | let _n = &(1isize + isize::MAX); + | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:130:15 + | +LL | let _n = &(1i128 + i128::MAX); + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:127:15 + | +LL | let _n = &(1i64 + i64::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:124:15 + | +LL | let _n = &(1i32 + i32::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:121:15 + | +LL | let _n = &(1i16 + i16::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:118:15 + | +LL | let _n = &(1i8 + i8::MAX); + | ^^^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:115:15 + | +LL | let _n = &(1u128 + u128::MAX); + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:112:15 + | +LL | let _n = &(1u64 + u64::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:109:15 + | +LL | let _n = &(1u32 + u32::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:106:15 + | +LL | let _n = &(1u16 + u16::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:103:15 + | +LL | let _n = &(1u8 + u8::MAX); + | ^^^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:98:15 + | +LL | let _n = &(1_usize >> BITS); + | ^^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:95:15 + | +LL | let _n = &(1_isize >> BITS); + | ^^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:92:15 + | +LL | let _n = &(1i128 >> 128); + | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:89:15 + | +LL | let _n = &(1i64 >> 64); + | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:86:15 + | +LL | let _n = &(1i32 >> 32); + | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:83:15 + | +LL | let _n = &(1i16 >> 16); + | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:80:15 + | +LL | let _n = &(1i8 >> 8); + | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:77:15 + | +LL | let _n = &(1u128 >> 128); + | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:74:15 + | +LL | let _n = &(1u64 >> 64); + | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:71:15 + | +LL | let _n = &(1u32 >> 32); + | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:68:15 + | +LL | let _n = &(1u16 >> 16); + | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:65:15 + | +LL | let _n = &(1u8 >> 8); + | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:60:15 + | +LL | let _n = &(1_usize << BITS); + | ^^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:57:15 + | +LL | let _n = &(1_isize << BITS); + | ^^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:54:15 + | +LL | let _n = &(1i128 << 128); + | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:51:15 + | +LL | let _n = &(1i64 << 64); + | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:48:15 + | +LL | let _n = &(1i32 << 32); + | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:45:15 + | +LL | let _n = &(1i16 << 16); + | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:42:15 + | +LL | let _n = &(1i8 << 8); + | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:39:15 + | +LL | let _n = &(1u128 << 128); + | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:36:15 + | +LL | let _n = &(1u64 << 64); + | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:33:15 + | +LL | let _n = &(1u32 << 32); + | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:30:15 + | +LL | let _n = &(1u16 << 16); + | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:27:15 + | +LL | let _n = &(1u8 << 8); + | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:29:14 + | +LL | let _n = 1u16 << 16; + | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:32:14 + | +LL | let _n = 1u32 << 32; + | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:35:14 + | +LL | let _n = 1u64 << 64; + | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:38:14 + | +LL | let _n = 1u128 << 128; + | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:41:14 + | +LL | let _n = 1i8 << 8; + | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:44:14 + | +LL | let _n = 1i16 << 16; + | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:47:14 + | +LL | let _n = 1i32 << 32; + | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:50:14 + | +LL | let _n = 1i64 << 64; + | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:53:14 + | +LL | let _n = 1i128 << 128; + | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:56:14 + | +LL | let _n = 1_isize << BITS; + | ^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:59:14 + | +LL | let _n = 1_usize << BITS; + | ^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:64:14 + | +LL | let _n = 1u8 >> 8; + | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:67:14 + | +LL | let _n = 1u16 >> 16; + | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:70:14 + | +LL | let _n = 1u32 >> 32; + | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:73:14 + | +LL | let _n = 1u64 >> 64; + | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:76:14 + | +LL | let _n = 1u128 >> 128; + | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:79:14 + | +LL | let _n = 1i8 >> 8; + | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:82:14 + | +LL | let _n = 1i16 >> 16; + | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:85:14 + | +LL | let _n = 1i32 >> 32; + | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:88:14 + | +LL | let _n = 1i64 >> 64; + | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:91:14 + | +LL | let _n = 1i128 >> 128; + | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:94:14 + | +LL | let _n = 1_isize >> BITS; + | ^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:97:14 + | +LL | let _n = 1_usize >> BITS; + | ^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:102:14 + | +LL | let _n = 1u8 + u8::MAX; + | ^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:105:14 + | +LL | let _n = 1u16 + u16::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:108:14 + | +LL | let _n = 1u32 + u32::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:111:14 + | +LL | let _n = 1u64 + u64::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:114:14 + | +LL | let _n = 1u128 + u128::MAX; + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:117:14 + | +LL | let _n = 1i8 + i8::MAX; + | ^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:120:14 + | +LL | let _n = 1i16 + i16::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:123:14 + | +LL | let _n = 1i32 + i32::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:126:14 + | +LL | let _n = 1i64 + i64::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:129:14 + | +LL | let _n = 1i128 + i128::MAX; + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:132:14 + | +LL | let _n = 1isize + isize::MAX; + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:135:14 + | +LL | let _n = 1usize + usize::MAX; + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:140:14 + | +LL | let _n = 1u8 - 5; + | ^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:143:14 + | +LL | let _n = 1u16 - 5; + | ^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:146:14 + | +LL | let _n = 1u32 - 5; + | ^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:149:14 + | +LL | let _n = 1u64 - 5 ; + | ^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:152:14 + | +LL | let _n = 1u128 - 5 ; + | ^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:155:14 + | +LL | let _n = -5i8 - i8::MAX; + | ^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:158:14 + | +LL | let _n = -5i16 - i16::MAX; + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:161:14 + | +LL | let _n = -5i32 - i32::MAX; + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:164:14 + | +LL | let _n = -5i64 - i64::MAX; + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:167:14 + | +LL | let _n = -5i128 - i128::MAX; + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:170:14 + | +LL | let _n = -5isize - isize::MAX; + | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:173:14 + | +LL | let _n = 1usize - 5; + | ^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:178:14 + | +LL | let _n = u8::MAX * 5; + | ^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:181:14 + | +LL | let _n = u16::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:184:14 + | +LL | let _n = u32::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:187:14 + | +LL | let _n = u64::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:190:14 + | +LL | let _n = u128::MAX * 5; + | ^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:193:14 + | +LL | let _n = i8::MAX * i8::MAX; + | ^^^^^^^^^^^^^^^^^ attempt to compute `i8::MAX * i8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:196:14 + | +LL | let _n = i16::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:199:14 + | +LL | let _n = i32::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:202:14 + | +LL | let _n = i64::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:205:14 + | +LL | let _n = i128::MAX * 5; + | ^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:208:14 + | +LL | let _n = isize::MAX * 5; + | ^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:211:14 + | +LL | let _n = usize::MAX * 5; + | ^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:216:14 + | +LL | let _n = 1u8 / 0; + | ^^^^^^^ attempt to divide `1_u8` by zero + | + = note: `#[deny(unconditional_panic)]` on by default + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:217:15 + | +LL | let _n = &(1u8 / 0); + | ^^^^^^^^^ attempt to divide `1_u8` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:219:14 + | +LL | let _n = 1u16 / 0; + | ^^^^^^^^ attempt to divide `1_u16` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:220:15 + | +LL | let _n = &(1u16 / 0); + | ^^^^^^^^^^ attempt to divide `1_u16` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:222:14 + | +LL | let _n = 1u32 / 0; + | ^^^^^^^^ attempt to divide `1_u32` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:223:15 + | +LL | let _n = &(1u32 / 0); + | ^^^^^^^^^^ attempt to divide `1_u32` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:225:14 + | +LL | let _n = 1u64 / 0; + | ^^^^^^^^ attempt to divide `1_u64` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:226:15 + | +LL | let _n = &(1u64 / 0); + | ^^^^^^^^^^ attempt to divide `1_u64` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:228:14 + | +LL | let _n = 1u128 / 0; + | ^^^^^^^^^ attempt to divide `1_u128` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:229:15 + | +LL | let _n = &(1u128 / 0); + | ^^^^^^^^^^^ attempt to divide `1_u128` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:231:14 + | +LL | let _n = 1i8 / 0; + | ^^^^^^^ attempt to divide `1_i8` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:232:15 + | +LL | let _n = &(1i8 / 0); + | ^^^^^^^^^ attempt to divide `1_i8` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:234:14 + | +LL | let _n = 1i16 / 0; + | ^^^^^^^^ attempt to divide `1_i16` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:235:15 + | +LL | let _n = &(1i16 / 0); + | ^^^^^^^^^^ attempt to divide `1_i16` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:237:14 + | +LL | let _n = 1i32 / 0; + | ^^^^^^^^ attempt to divide `1_i32` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:238:15 + | +LL | let _n = &(1i32 / 0); + | ^^^^^^^^^^ attempt to divide `1_i32` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:240:14 + | +LL | let _n = 1i64 / 0; + | ^^^^^^^^ attempt to divide `1_i64` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:241:15 + | +LL | let _n = &(1i64 / 0); + | ^^^^^^^^^^ attempt to divide `1_i64` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:243:14 + | +LL | let _n = 1i128 / 0; + | ^^^^^^^^^ attempt to divide `1_i128` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:244:15 + | +LL | let _n = &(1i128 / 0); + | ^^^^^^^^^^^ attempt to divide `1_i128` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:246:14 + | +LL | let _n = 1isize / 0; + | ^^^^^^^^^^ attempt to divide `1_isize` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:247:15 + | +LL | let _n = &(1isize / 0); + | ^^^^^^^^^^^^ attempt to divide `1_isize` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:249:14 + | +LL | let _n = 1usize / 0; + | ^^^^^^^^^^ attempt to divide `1_usize` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:250:15 + | +LL | let _n = &(1usize / 0); + | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:254:14 + | +LL | let _n = 1u8 % 0; + | ^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:255:15 + | +LL | let _n = &(1u8 % 0); + | ^^^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:257:14 + | +LL | let _n = 1u16 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:258:15 + | +LL | let _n = &(1u16 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:260:14 + | +LL | let _n = 1u32 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:261:15 + | +LL | let _n = &(1u32 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:263:14 + | +LL | let _n = 1u64 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:264:15 + | +LL | let _n = &(1u64 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:266:14 + | +LL | let _n = 1u128 % 0; + | ^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:267:15 + | +LL | let _n = &(1u128 % 0); + | ^^^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:269:14 + | +LL | let _n = 1i8 % 0; + | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:270:15 + | +LL | let _n = &(1i8 % 0); + | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:272:14 + | +LL | let _n = 1i16 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:273:15 + | +LL | let _n = &(1i16 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:275:14 + | +LL | let _n = 1i32 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:276:15 + | +LL | let _n = &(1i32 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:278:14 + | +LL | let _n = 1i64 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:279:15 + | +LL | let _n = &(1i64 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:281:14 + | +LL | let _n = 1i128 % 0; + | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:282:15 + | +LL | let _n = &(1i128 % 0); + | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:284:14 + | +LL | let _n = 1isize % 0; + | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:285:15 + | +LL | let _n = &(1isize % 0); + | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:287:14 + | +LL | let _n = 1usize % 0; + | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:288:15 + | +LL | let _n = &(1usize % 0); + | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:292:14 + | +LL | let _n = [1, 2, 3][4]; + | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:293:15 + | +LL | let _n = &([1, 2, 3][4]); + | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + +error: aborting due to 170 previous errors + diff --git a/tests/ui/lint/lint-overflowing-ops.opt.stderr b/tests/ui/lint/lint-overflowing-ops.opt.stderr new file mode 100644 index 0000000000000..93fc19ce79e44 --- /dev/null +++ b/tests/ui/lint/lint-overflowing-ops.opt.stderr @@ -0,0 +1,1030 @@ +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:26:14 + | +LL | let _n = 1u8 << 8; + | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | +note: the lint level is defined here + --> $DIR/lint-overflowing-ops.rs:17:9 + | +LL | #![deny(arithmetic_overflow)] + | ^^^^^^^^^^^^^^^^^^^ + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:212:15 + | +LL | let _n = &(usize::MAX * 5); + | ^^^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:209:15 + | +LL | let _n = &(isize::MAX * 5); + | ^^^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:206:15 + | +LL | let _n = &(i128::MAX * 5); + | ^^^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:203:15 + | +LL | let _n = &(i64::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:200:15 + | +LL | let _n = &(i32::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:197:15 + | +LL | let _n = &(i16::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:194:15 + | +LL | let _n = &(i8::MAX * i8::MAX); + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `i8::MAX * i8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:191:15 + | +LL | let _n = &(u128::MAX * 5); + | ^^^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:188:15 + | +LL | let _n = &(u64::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:185:15 + | +LL | let _n = &(u32::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:182:15 + | +LL | let _n = &(u16::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:179:15 + | +LL | let _n = &(u8::MAX * 5); + | ^^^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:174:15 + | +LL | let _n = &(1usize - 5); + | ^^^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:171:15 + | +LL | let _n = &(-5isize - isize::MAX); + | ^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:168:15 + | +LL | let _n = &(-5i128 - i128::MAX); + | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:165:15 + | +LL | let _n = &(-5i64 - i64::MAX); + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:162:15 + | +LL | let _n = &(-5i32 - i32::MAX); + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:159:15 + | +LL | let _n = &(-5i16 - i16::MAX); + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:156:15 + | +LL | let _n = &(-5i8 - i8::MAX); + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:153:15 + | +LL | let _n = &(1u128 - 5); + | ^^^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:150:15 + | +LL | let _n = &(1u64 - 5); + | ^^^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:147:15 + | +LL | let _n = &(1u32 - 5); + | ^^^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:144:15 + | +LL | let _n = &(1u16 - 5); + | ^^^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:141:15 + | +LL | let _n = &(1u8 - 5); + | ^^^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:136:15 + | +LL | let _n = &(1usize + usize::MAX); + | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:133:15 + | +LL | let _n = &(1isize + isize::MAX); + | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:130:15 + | +LL | let _n = &(1i128 + i128::MAX); + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:127:15 + | +LL | let _n = &(1i64 + i64::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:124:15 + | +LL | let _n = &(1i32 + i32::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:121:15 + | +LL | let _n = &(1i16 + i16::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:118:15 + | +LL | let _n = &(1i8 + i8::MAX); + | ^^^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:115:15 + | +LL | let _n = &(1u128 + u128::MAX); + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:112:15 + | +LL | let _n = &(1u64 + u64::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:109:15 + | +LL | let _n = &(1u32 + u32::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:106:15 + | +LL | let _n = &(1u16 + u16::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:103:15 + | +LL | let _n = &(1u8 + u8::MAX); + | ^^^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:98:15 + | +LL | let _n = &(1_usize >> BITS); + | ^^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:95:15 + | +LL | let _n = &(1_isize >> BITS); + | ^^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:92:15 + | +LL | let _n = &(1i128 >> 128); + | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:89:15 + | +LL | let _n = &(1i64 >> 64); + | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:86:15 + | +LL | let _n = &(1i32 >> 32); + | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:83:15 + | +LL | let _n = &(1i16 >> 16); + | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:80:15 + | +LL | let _n = &(1i8 >> 8); + | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:77:15 + | +LL | let _n = &(1u128 >> 128); + | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:74:15 + | +LL | let _n = &(1u64 >> 64); + | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:71:15 + | +LL | let _n = &(1u32 >> 32); + | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:68:15 + | +LL | let _n = &(1u16 >> 16); + | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:65:15 + | +LL | let _n = &(1u8 >> 8); + | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:60:15 + | +LL | let _n = &(1_usize << BITS); + | ^^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:57:15 + | +LL | let _n = &(1_isize << BITS); + | ^^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:54:15 + | +LL | let _n = &(1i128 << 128); + | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:51:15 + | +LL | let _n = &(1i64 << 64); + | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:48:15 + | +LL | let _n = &(1i32 << 32); + | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:45:15 + | +LL | let _n = &(1i16 << 16); + | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:42:15 + | +LL | let _n = &(1i8 << 8); + | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:39:15 + | +LL | let _n = &(1u128 << 128); + | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:36:15 + | +LL | let _n = &(1u64 << 64); + | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:33:15 + | +LL | let _n = &(1u32 << 32); + | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:30:15 + | +LL | let _n = &(1u16 << 16); + | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:27:15 + | +LL | let _n = &(1u8 << 8); + | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:29:14 + | +LL | let _n = 1u16 << 16; + | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:32:14 + | +LL | let _n = 1u32 << 32; + | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:35:14 + | +LL | let _n = 1u64 << 64; + | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:38:14 + | +LL | let _n = 1u128 << 128; + | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:41:14 + | +LL | let _n = 1i8 << 8; + | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:44:14 + | +LL | let _n = 1i16 << 16; + | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:47:14 + | +LL | let _n = 1i32 << 32; + | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:50:14 + | +LL | let _n = 1i64 << 64; + | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:53:14 + | +LL | let _n = 1i128 << 128; + | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:56:14 + | +LL | let _n = 1_isize << BITS; + | ^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:59:14 + | +LL | let _n = 1_usize << BITS; + | ^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:64:14 + | +LL | let _n = 1u8 >> 8; + | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:67:14 + | +LL | let _n = 1u16 >> 16; + | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:70:14 + | +LL | let _n = 1u32 >> 32; + | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:73:14 + | +LL | let _n = 1u64 >> 64; + | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:76:14 + | +LL | let _n = 1u128 >> 128; + | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:79:14 + | +LL | let _n = 1i8 >> 8; + | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:82:14 + | +LL | let _n = 1i16 >> 16; + | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:85:14 + | +LL | let _n = 1i32 >> 32; + | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:88:14 + | +LL | let _n = 1i64 >> 64; + | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:91:14 + | +LL | let _n = 1i128 >> 128; + | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:94:14 + | +LL | let _n = 1_isize >> BITS; + | ^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:97:14 + | +LL | let _n = 1_usize >> BITS; + | ^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:102:14 + | +LL | let _n = 1u8 + u8::MAX; + | ^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:105:14 + | +LL | let _n = 1u16 + u16::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:108:14 + | +LL | let _n = 1u32 + u32::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:111:14 + | +LL | let _n = 1u64 + u64::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:114:14 + | +LL | let _n = 1u128 + u128::MAX; + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:117:14 + | +LL | let _n = 1i8 + i8::MAX; + | ^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:120:14 + | +LL | let _n = 1i16 + i16::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:123:14 + | +LL | let _n = 1i32 + i32::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:126:14 + | +LL | let _n = 1i64 + i64::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:129:14 + | +LL | let _n = 1i128 + i128::MAX; + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:132:14 + | +LL | let _n = 1isize + isize::MAX; + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:135:14 + | +LL | let _n = 1usize + usize::MAX; + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:140:14 + | +LL | let _n = 1u8 - 5; + | ^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:143:14 + | +LL | let _n = 1u16 - 5; + | ^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:146:14 + | +LL | let _n = 1u32 - 5; + | ^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:149:14 + | +LL | let _n = 1u64 - 5 ; + | ^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:152:14 + | +LL | let _n = 1u128 - 5 ; + | ^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:155:14 + | +LL | let _n = -5i8 - i8::MAX; + | ^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:158:14 + | +LL | let _n = -5i16 - i16::MAX; + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:161:14 + | +LL | let _n = -5i32 - i32::MAX; + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:164:14 + | +LL | let _n = -5i64 - i64::MAX; + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:167:14 + | +LL | let _n = -5i128 - i128::MAX; + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:170:14 + | +LL | let _n = -5isize - isize::MAX; + | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:173:14 + | +LL | let _n = 1usize - 5; + | ^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:178:14 + | +LL | let _n = u8::MAX * 5; + | ^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:181:14 + | +LL | let _n = u16::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:184:14 + | +LL | let _n = u32::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:187:14 + | +LL | let _n = u64::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:190:14 + | +LL | let _n = u128::MAX * 5; + | ^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:193:14 + | +LL | let _n = i8::MAX * i8::MAX; + | ^^^^^^^^^^^^^^^^^ attempt to compute `i8::MAX * i8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:196:14 + | +LL | let _n = i16::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:199:14 + | +LL | let _n = i32::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:202:14 + | +LL | let _n = i64::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:205:14 + | +LL | let _n = i128::MAX * 5; + | ^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:208:14 + | +LL | let _n = isize::MAX * 5; + | ^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:211:14 + | +LL | let _n = usize::MAX * 5; + | ^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:216:14 + | +LL | let _n = 1u8 / 0; + | ^^^^^^^ attempt to divide `1_u8` by zero + | + = note: `#[deny(unconditional_panic)]` on by default + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:217:15 + | +LL | let _n = &(1u8 / 0); + | ^^^^^^^^^ attempt to divide `1_u8` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:219:14 + | +LL | let _n = 1u16 / 0; + | ^^^^^^^^ attempt to divide `1_u16` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:220:15 + | +LL | let _n = &(1u16 / 0); + | ^^^^^^^^^^ attempt to divide `1_u16` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:222:14 + | +LL | let _n = 1u32 / 0; + | ^^^^^^^^ attempt to divide `1_u32` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:223:15 + | +LL | let _n = &(1u32 / 0); + | ^^^^^^^^^^ attempt to divide `1_u32` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:225:14 + | +LL | let _n = 1u64 / 0; + | ^^^^^^^^ attempt to divide `1_u64` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:226:15 + | +LL | let _n = &(1u64 / 0); + | ^^^^^^^^^^ attempt to divide `1_u64` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:228:14 + | +LL | let _n = 1u128 / 0; + | ^^^^^^^^^ attempt to divide `1_u128` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:229:15 + | +LL | let _n = &(1u128 / 0); + | ^^^^^^^^^^^ attempt to divide `1_u128` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:231:14 + | +LL | let _n = 1i8 / 0; + | ^^^^^^^ attempt to divide `1_i8` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:232:15 + | +LL | let _n = &(1i8 / 0); + | ^^^^^^^^^ attempt to divide `1_i8` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:234:14 + | +LL | let _n = 1i16 / 0; + | ^^^^^^^^ attempt to divide `1_i16` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:235:15 + | +LL | let _n = &(1i16 / 0); + | ^^^^^^^^^^ attempt to divide `1_i16` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:237:14 + | +LL | let _n = 1i32 / 0; + | ^^^^^^^^ attempt to divide `1_i32` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:238:15 + | +LL | let _n = &(1i32 / 0); + | ^^^^^^^^^^ attempt to divide `1_i32` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:240:14 + | +LL | let _n = 1i64 / 0; + | ^^^^^^^^ attempt to divide `1_i64` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:241:15 + | +LL | let _n = &(1i64 / 0); + | ^^^^^^^^^^ attempt to divide `1_i64` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:243:14 + | +LL | let _n = 1i128 / 0; + | ^^^^^^^^^ attempt to divide `1_i128` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:244:15 + | +LL | let _n = &(1i128 / 0); + | ^^^^^^^^^^^ attempt to divide `1_i128` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:246:14 + | +LL | let _n = 1isize / 0; + | ^^^^^^^^^^ attempt to divide `1_isize` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:247:15 + | +LL | let _n = &(1isize / 0); + | ^^^^^^^^^^^^ attempt to divide `1_isize` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:249:14 + | +LL | let _n = 1usize / 0; + | ^^^^^^^^^^ attempt to divide `1_usize` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:250:15 + | +LL | let _n = &(1usize / 0); + | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:254:14 + | +LL | let _n = 1u8 % 0; + | ^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:255:15 + | +LL | let _n = &(1u8 % 0); + | ^^^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:257:14 + | +LL | let _n = 1u16 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:258:15 + | +LL | let _n = &(1u16 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:260:14 + | +LL | let _n = 1u32 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:261:15 + | +LL | let _n = &(1u32 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:263:14 + | +LL | let _n = 1u64 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:264:15 + | +LL | let _n = &(1u64 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:266:14 + | +LL | let _n = 1u128 % 0; + | ^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:267:15 + | +LL | let _n = &(1u128 % 0); + | ^^^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:269:14 + | +LL | let _n = 1i8 % 0; + | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:270:15 + | +LL | let _n = &(1i8 % 0); + | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:272:14 + | +LL | let _n = 1i16 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:273:15 + | +LL | let _n = &(1i16 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:275:14 + | +LL | let _n = 1i32 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:276:15 + | +LL | let _n = &(1i32 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:278:14 + | +LL | let _n = 1i64 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:279:15 + | +LL | let _n = &(1i64 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:281:14 + | +LL | let _n = 1i128 % 0; + | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:282:15 + | +LL | let _n = &(1i128 % 0); + | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:284:14 + | +LL | let _n = 1isize % 0; + | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:285:15 + | +LL | let _n = &(1isize % 0); + | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:287:14 + | +LL | let _n = 1usize % 0; + | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:288:15 + | +LL | let _n = &(1usize % 0); + | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:292:14 + | +LL | let _n = [1, 2, 3][4]; + | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:293:15 + | +LL | let _n = &([1, 2, 3][4]); + | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + +error: aborting due to 170 previous errors + diff --git a/tests/ui/lint/lint-overflowing-ops.opt_with_overflow_checks.stderr b/tests/ui/lint/lint-overflowing-ops.opt_with_overflow_checks.stderr new file mode 100644 index 0000000000000..93fc19ce79e44 --- /dev/null +++ b/tests/ui/lint/lint-overflowing-ops.opt_with_overflow_checks.stderr @@ -0,0 +1,1030 @@ +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:26:14 + | +LL | let _n = 1u8 << 8; + | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | +note: the lint level is defined here + --> $DIR/lint-overflowing-ops.rs:17:9 + | +LL | #![deny(arithmetic_overflow)] + | ^^^^^^^^^^^^^^^^^^^ + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:212:15 + | +LL | let _n = &(usize::MAX * 5); + | ^^^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:209:15 + | +LL | let _n = &(isize::MAX * 5); + | ^^^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:206:15 + | +LL | let _n = &(i128::MAX * 5); + | ^^^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:203:15 + | +LL | let _n = &(i64::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:200:15 + | +LL | let _n = &(i32::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:197:15 + | +LL | let _n = &(i16::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:194:15 + | +LL | let _n = &(i8::MAX * i8::MAX); + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `i8::MAX * i8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:191:15 + | +LL | let _n = &(u128::MAX * 5); + | ^^^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:188:15 + | +LL | let _n = &(u64::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:185:15 + | +LL | let _n = &(u32::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:182:15 + | +LL | let _n = &(u16::MAX * 5); + | ^^^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:179:15 + | +LL | let _n = &(u8::MAX * 5); + | ^^^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:174:15 + | +LL | let _n = &(1usize - 5); + | ^^^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:171:15 + | +LL | let _n = &(-5isize - isize::MAX); + | ^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:168:15 + | +LL | let _n = &(-5i128 - i128::MAX); + | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:165:15 + | +LL | let _n = &(-5i64 - i64::MAX); + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:162:15 + | +LL | let _n = &(-5i32 - i32::MAX); + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:159:15 + | +LL | let _n = &(-5i16 - i16::MAX); + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:156:15 + | +LL | let _n = &(-5i8 - i8::MAX); + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:153:15 + | +LL | let _n = &(1u128 - 5); + | ^^^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:150:15 + | +LL | let _n = &(1u64 - 5); + | ^^^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:147:15 + | +LL | let _n = &(1u32 - 5); + | ^^^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:144:15 + | +LL | let _n = &(1u16 - 5); + | ^^^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:141:15 + | +LL | let _n = &(1u8 - 5); + | ^^^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:136:15 + | +LL | let _n = &(1usize + usize::MAX); + | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:133:15 + | +LL | let _n = &(1isize + isize::MAX); + | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:130:15 + | +LL | let _n = &(1i128 + i128::MAX); + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:127:15 + | +LL | let _n = &(1i64 + i64::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:124:15 + | +LL | let _n = &(1i32 + i32::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:121:15 + | +LL | let _n = &(1i16 + i16::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:118:15 + | +LL | let _n = &(1i8 + i8::MAX); + | ^^^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:115:15 + | +LL | let _n = &(1u128 + u128::MAX); + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:112:15 + | +LL | let _n = &(1u64 + u64::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:109:15 + | +LL | let _n = &(1u32 + u32::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:106:15 + | +LL | let _n = &(1u16 + u16::MAX); + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:103:15 + | +LL | let _n = &(1u8 + u8::MAX); + | ^^^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:98:15 + | +LL | let _n = &(1_usize >> BITS); + | ^^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:95:15 + | +LL | let _n = &(1_isize >> BITS); + | ^^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:92:15 + | +LL | let _n = &(1i128 >> 128); + | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:89:15 + | +LL | let _n = &(1i64 >> 64); + | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:86:15 + | +LL | let _n = &(1i32 >> 32); + | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:83:15 + | +LL | let _n = &(1i16 >> 16); + | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:80:15 + | +LL | let _n = &(1i8 >> 8); + | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:77:15 + | +LL | let _n = &(1u128 >> 128); + | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:74:15 + | +LL | let _n = &(1u64 >> 64); + | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:71:15 + | +LL | let _n = &(1u32 >> 32); + | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:68:15 + | +LL | let _n = &(1u16 >> 16); + | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:65:15 + | +LL | let _n = &(1u8 >> 8); + | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:60:15 + | +LL | let _n = &(1_usize << BITS); + | ^^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:57:15 + | +LL | let _n = &(1_isize << BITS); + | ^^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:54:15 + | +LL | let _n = &(1i128 << 128); + | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:51:15 + | +LL | let _n = &(1i64 << 64); + | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:48:15 + | +LL | let _n = &(1i32 << 32); + | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:45:15 + | +LL | let _n = &(1i16 << 16); + | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:42:15 + | +LL | let _n = &(1i8 << 8); + | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:39:15 + | +LL | let _n = &(1u128 << 128); + | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:36:15 + | +LL | let _n = &(1u64 << 64); + | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:33:15 + | +LL | let _n = &(1u32 << 32); + | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:30:15 + | +LL | let _n = &(1u16 << 16); + | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:27:15 + | +LL | let _n = &(1u8 << 8); + | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:29:14 + | +LL | let _n = 1u16 << 16; + | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:32:14 + | +LL | let _n = 1u32 << 32; + | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:35:14 + | +LL | let _n = 1u64 << 64; + | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:38:14 + | +LL | let _n = 1u128 << 128; + | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:41:14 + | +LL | let _n = 1i8 << 8; + | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:44:14 + | +LL | let _n = 1i16 << 16; + | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:47:14 + | +LL | let _n = 1i32 << 32; + | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:50:14 + | +LL | let _n = 1i64 << 64; + | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:53:14 + | +LL | let _n = 1i128 << 128; + | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:56:14 + | +LL | let _n = 1_isize << BITS; + | ^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:59:14 + | +LL | let _n = 1_usize << BITS; + | ^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:64:14 + | +LL | let _n = 1u8 >> 8; + | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:67:14 + | +LL | let _n = 1u16 >> 16; + | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:70:14 + | +LL | let _n = 1u32 >> 32; + | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:73:14 + | +LL | let _n = 1u64 >> 64; + | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:76:14 + | +LL | let _n = 1u128 >> 128; + | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:79:14 + | +LL | let _n = 1i8 >> 8; + | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:82:14 + | +LL | let _n = 1i16 >> 16; + | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:85:14 + | +LL | let _n = 1i32 >> 32; + | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:88:14 + | +LL | let _n = 1i64 >> 64; + | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:91:14 + | +LL | let _n = 1i128 >> 128; + | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:94:14 + | +LL | let _n = 1_isize >> BITS; + | ^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:97:14 + | +LL | let _n = 1_usize >> BITS; + | ^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:102:14 + | +LL | let _n = 1u8 + u8::MAX; + | ^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:105:14 + | +LL | let _n = 1u16 + u16::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:108:14 + | +LL | let _n = 1u32 + u32::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:111:14 + | +LL | let _n = 1u64 + u64::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:114:14 + | +LL | let _n = 1u128 + u128::MAX; + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:117:14 + | +LL | let _n = 1i8 + i8::MAX; + | ^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:120:14 + | +LL | let _n = 1i16 + i16::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:123:14 + | +LL | let _n = 1i32 + i32::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:126:14 + | +LL | let _n = 1i64 + i64::MAX; + | ^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:129:14 + | +LL | let _n = 1i128 + i128::MAX; + | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:132:14 + | +LL | let _n = 1isize + isize::MAX; + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:135:14 + | +LL | let _n = 1usize + usize::MAX; + | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:140:14 + | +LL | let _n = 1u8 - 5; + | ^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:143:14 + | +LL | let _n = 1u16 - 5; + | ^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:146:14 + | +LL | let _n = 1u32 - 5; + | ^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:149:14 + | +LL | let _n = 1u64 - 5 ; + | ^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:152:14 + | +LL | let _n = 1u128 - 5 ; + | ^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:155:14 + | +LL | let _n = -5i8 - i8::MAX; + | ^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:158:14 + | +LL | let _n = -5i16 - i16::MAX; + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:161:14 + | +LL | let _n = -5i32 - i32::MAX; + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:164:14 + | +LL | let _n = -5i64 - i64::MAX; + | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:167:14 + | +LL | let _n = -5i128 - i128::MAX; + | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:170:14 + | +LL | let _n = -5isize - isize::MAX; + | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:173:14 + | +LL | let _n = 1usize - 5; + | ^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:178:14 + | +LL | let _n = u8::MAX * 5; + | ^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:181:14 + | +LL | let _n = u16::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:184:14 + | +LL | let _n = u32::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:187:14 + | +LL | let _n = u64::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:190:14 + | +LL | let _n = u128::MAX * 5; + | ^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:193:14 + | +LL | let _n = i8::MAX * i8::MAX; + | ^^^^^^^^^^^^^^^^^ attempt to compute `i8::MAX * i8::MAX`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:196:14 + | +LL | let _n = i16::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:199:14 + | +LL | let _n = i32::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:202:14 + | +LL | let _n = i64::MAX * 5; + | ^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:205:14 + | +LL | let _n = i128::MAX * 5; + | ^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:208:14 + | +LL | let _n = isize::MAX * 5; + | ^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:211:14 + | +LL | let _n = usize::MAX * 5; + | ^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:216:14 + | +LL | let _n = 1u8 / 0; + | ^^^^^^^ attempt to divide `1_u8` by zero + | + = note: `#[deny(unconditional_panic)]` on by default + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:217:15 + | +LL | let _n = &(1u8 / 0); + | ^^^^^^^^^ attempt to divide `1_u8` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:219:14 + | +LL | let _n = 1u16 / 0; + | ^^^^^^^^ attempt to divide `1_u16` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:220:15 + | +LL | let _n = &(1u16 / 0); + | ^^^^^^^^^^ attempt to divide `1_u16` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:222:14 + | +LL | let _n = 1u32 / 0; + | ^^^^^^^^ attempt to divide `1_u32` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:223:15 + | +LL | let _n = &(1u32 / 0); + | ^^^^^^^^^^ attempt to divide `1_u32` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:225:14 + | +LL | let _n = 1u64 / 0; + | ^^^^^^^^ attempt to divide `1_u64` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:226:15 + | +LL | let _n = &(1u64 / 0); + | ^^^^^^^^^^ attempt to divide `1_u64` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:228:14 + | +LL | let _n = 1u128 / 0; + | ^^^^^^^^^ attempt to divide `1_u128` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:229:15 + | +LL | let _n = &(1u128 / 0); + | ^^^^^^^^^^^ attempt to divide `1_u128` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:231:14 + | +LL | let _n = 1i8 / 0; + | ^^^^^^^ attempt to divide `1_i8` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:232:15 + | +LL | let _n = &(1i8 / 0); + | ^^^^^^^^^ attempt to divide `1_i8` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:234:14 + | +LL | let _n = 1i16 / 0; + | ^^^^^^^^ attempt to divide `1_i16` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:235:15 + | +LL | let _n = &(1i16 / 0); + | ^^^^^^^^^^ attempt to divide `1_i16` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:237:14 + | +LL | let _n = 1i32 / 0; + | ^^^^^^^^ attempt to divide `1_i32` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:238:15 + | +LL | let _n = &(1i32 / 0); + | ^^^^^^^^^^ attempt to divide `1_i32` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:240:14 + | +LL | let _n = 1i64 / 0; + | ^^^^^^^^ attempt to divide `1_i64` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:241:15 + | +LL | let _n = &(1i64 / 0); + | ^^^^^^^^^^ attempt to divide `1_i64` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:243:14 + | +LL | let _n = 1i128 / 0; + | ^^^^^^^^^ attempt to divide `1_i128` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:244:15 + | +LL | let _n = &(1i128 / 0); + | ^^^^^^^^^^^ attempt to divide `1_i128` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:246:14 + | +LL | let _n = 1isize / 0; + | ^^^^^^^^^^ attempt to divide `1_isize` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:247:15 + | +LL | let _n = &(1isize / 0); + | ^^^^^^^^^^^^ attempt to divide `1_isize` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:249:14 + | +LL | let _n = 1usize / 0; + | ^^^^^^^^^^ attempt to divide `1_usize` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:250:15 + | +LL | let _n = &(1usize / 0); + | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:254:14 + | +LL | let _n = 1u8 % 0; + | ^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:255:15 + | +LL | let _n = &(1u8 % 0); + | ^^^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:257:14 + | +LL | let _n = 1u16 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:258:15 + | +LL | let _n = &(1u16 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:260:14 + | +LL | let _n = 1u32 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:261:15 + | +LL | let _n = &(1u32 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:263:14 + | +LL | let _n = 1u64 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:264:15 + | +LL | let _n = &(1u64 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:266:14 + | +LL | let _n = 1u128 % 0; + | ^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:267:15 + | +LL | let _n = &(1u128 % 0); + | ^^^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:269:14 + | +LL | let _n = 1i8 % 0; + | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:270:15 + | +LL | let _n = &(1i8 % 0); + | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:272:14 + | +LL | let _n = 1i16 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:273:15 + | +LL | let _n = &(1i16 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:275:14 + | +LL | let _n = 1i32 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:276:15 + | +LL | let _n = &(1i32 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:278:14 + | +LL | let _n = 1i64 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:279:15 + | +LL | let _n = &(1i64 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:281:14 + | +LL | let _n = 1i128 % 0; + | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:282:15 + | +LL | let _n = &(1i128 % 0); + | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:284:14 + | +LL | let _n = 1isize % 0; + | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:285:15 + | +LL | let _n = &(1isize % 0); + | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:287:14 + | +LL | let _n = 1usize % 0; + | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:288:15 + | +LL | let _n = &(1usize % 0); + | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:292:14 + | +LL | let _n = [1, 2, 3][4]; + | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:293:15 + | +LL | let _n = &([1, 2, 3][4]); + | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + +error: aborting due to 170 previous errors + diff --git a/tests/ui/lint/lint-overflowing-ops.rs b/tests/ui/lint/lint-overflowing-ops.rs new file mode 100644 index 0000000000000..e64c210badeff --- /dev/null +++ b/tests/ui/lint/lint-overflowing-ops.rs @@ -0,0 +1,294 @@ +// Tests that overflowing or bound-exceeding operations +// are correclty linted including when they are const promoted + +// We are using "-Z deduplicate-diagnostics=yes" because different +// build configurations emit different number of duplicate diagnostics +// and this flag lets us test them all with a single .rs file like this + +//@ revisions: noopt opt opt_with_overflow_checks +//@ [noopt]compile-flags: -C opt-level=0 -Z deduplicate-diagnostics=yes +//@ [opt]compile-flags: -O +//@ [opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O -Z deduplicate-diagnostics=yes +//@ build-fail +//@ ignore-pass (test tests codegen-time behaviour) +//@ normalize-stderr-test "shift left by `(64|32)_usize`, which" -> "shift left by `%BITS%`, which" +//@ normalize-stderr-test "shift right by `(64|32)_usize`, which" -> "shift right by `%BITS%`, which" + +#![deny(arithmetic_overflow)] + +#[cfg(target_pointer_width = "32")] +const BITS: usize = 32; +#[cfg(target_pointer_width = "64")] +const BITS: usize = 64; + +fn main() { + // Shift left + let _n = 1u8 << 8; //~ ERROR: arithmetic operation will overflow + let _n = &(1u8 << 8); //~ ERROR: arithmetic operation will overflow + + let _n = 1u16 << 16; //~ ERROR: arithmetic operation will overflow + let _n = &(1u16 << 16); //~ ERROR: arithmetic operation will overflow + + let _n = 1u32 << 32; //~ ERROR: arithmetic operation will overflow + let _n = &(1u32 << 32); //~ ERROR: arithmetic operation will overflow + + let _n = 1u64 << 64; //~ ERROR: arithmetic operation will overflow + let _n = &(1u64 << 64); //~ ERROR: arithmetic operation will overflow + + let _n = 1u128 << 128; //~ ERROR: arithmetic operation will overflow + let _n = &(1u128 << 128); //~ ERROR: arithmetic operation will overflow + + let _n = 1i8 << 8; //~ ERROR: arithmetic operation will overflow + let _n = &(1i8 << 8); //~ ERROR: arithmetic operation will overflow + + let _n = 1i16 << 16; //~ ERROR: arithmetic operation will overflow + let _n = &(1i16 << 16); //~ ERROR: arithmetic operation will overflow + + let _n = 1i32 << 32; //~ ERROR: arithmetic operation will overflow + let _n = &(1i32 << 32); //~ ERROR: arithmetic operation will overflow + + let _n = 1i64 << 64; //~ ERROR: arithmetic operation will overflow + let _n = &(1i64 << 64); //~ ERROR: arithmetic operation will overflow + + let _n = 1i128 << 128; //~ ERROR: arithmetic operation will overflow + let _n = &(1i128 << 128); //~ ERROR: arithmetic operation will overflow + + let _n = 1_isize << BITS; //~ ERROR: arithmetic operation will overflow + let _n = &(1_isize << BITS); //~ ERROR: arithmetic operation will overflow + + let _n = 1_usize << BITS; //~ ERROR: arithmetic operation will overflow + let _n = &(1_usize << BITS); //~ ERROR: arithmetic operation will overflow + + + // Shift right + let _n = 1u8 >> 8; //~ ERROR: arithmetic operation will overflow + let _n = &(1u8 >> 8); //~ ERROR: arithmetic operation will overflow + + let _n = 1u16 >> 16; //~ ERROR: arithmetic operation will overflow + let _n = &(1u16 >> 16); //~ ERROR: arithmetic operation will overflow + + let _n = 1u32 >> 32; //~ ERROR: arithmetic operation will overflow + let _n = &(1u32 >> 32); //~ ERROR: arithmetic operation will overflow + + let _n = 1u64 >> 64; //~ ERROR: arithmetic operation will overflow + let _n = &(1u64 >> 64); //~ ERROR: arithmetic operation will overflow + + let _n = 1u128 >> 128; //~ ERROR: arithmetic operation will overflow + let _n = &(1u128 >> 128); //~ ERROR: arithmetic operation will overflow + + let _n = 1i8 >> 8; //~ ERROR: arithmetic operation will overflow + let _n = &(1i8 >> 8); //~ ERROR: arithmetic operation will overflow + + let _n = 1i16 >> 16; //~ ERROR: arithmetic operation will overflow + let _n = &(1i16 >> 16); //~ ERROR: arithmetic operation will overflow + + let _n = 1i32 >> 32; //~ ERROR: arithmetic operation will overflow + let _n = &(1i32 >> 32); //~ ERROR: arithmetic operation will overflow + + let _n = 1i64 >> 64; //~ ERROR: arithmetic operation will overflow + let _n = &(1i64 >> 64); //~ ERROR: arithmetic operation will overflow + + let _n = 1i128 >> 128; //~ ERROR: arithmetic operation will overflow + let _n = &(1i128 >> 128); //~ ERROR: arithmetic operation will overflow + + let _n = 1_isize >> BITS; //~ ERROR: arithmetic operation will overflow + let _n = &(1_isize >> BITS); //~ ERROR: arithmetic operation will overflow + + let _n = 1_usize >> BITS; //~ ERROR: arithmetic operation will overflow + let _n = &(1_usize >> BITS); //~ ERROR: arithmetic operation will overflow + + + // Addition + let _n = 1u8 + u8::MAX; //~ ERROR: arithmetic operation will overflow + let _n = &(1u8 + u8::MAX); //~ ERROR: arithmetic operation will overflow + + let _n = 1u16 + u16::MAX; //~ ERROR: arithmetic operation will overflow + let _n = &(1u16 + u16::MAX); //~ ERROR: arithmetic operation will overflow + + let _n = 1u32 + u32::MAX; //~ ERROR: arithmetic operation will overflow + let _n = &(1u32 + u32::MAX); //~ ERROR: arithmetic operation will overflow + + let _n = 1u64 + u64::MAX; //~ ERROR: arithmetic operation will overflow + let _n = &(1u64 + u64::MAX); //~ ERROR: arithmetic operation will overflow + + let _n = 1u128 + u128::MAX; //~ ERROR: arithmetic operation will overflow + let _n = &(1u128 + u128::MAX); //~ ERROR: arithmetic operation will overflow + + let _n = 1i8 + i8::MAX; //~ ERROR: arithmetic operation will overflow + let _n = &(1i8 + i8::MAX); //~ ERROR: arithmetic operation will overflow + + let _n = 1i16 + i16::MAX; //~ ERROR: arithmetic operation will overflow + let _n = &(1i16 + i16::MAX); //~ ERROR: arithmetic operation will overflow + + let _n = 1i32 + i32::MAX; //~ ERROR: arithmetic operation will overflow + let _n = &(1i32 + i32::MAX); //~ ERROR: arithmetic operation will overflow + + let _n = 1i64 + i64::MAX; //~ ERROR: arithmetic operation will overflow + let _n = &(1i64 + i64::MAX); //~ ERROR: arithmetic operation will overflow + + let _n = 1i128 + i128::MAX; //~ ERROR: arithmetic operation will overflow + let _n = &(1i128 + i128::MAX); //~ ERROR: arithmetic operation will overflow + + let _n = 1isize + isize::MAX; //~ ERROR: arithmetic operation will overflow + let _n = &(1isize + isize::MAX); //~ ERROR: arithmetic operation will overflow + + let _n = 1usize + usize::MAX; //~ ERROR: arithmetic operation will overflow + let _n = &(1usize + usize::MAX); //~ ERROR: arithmetic operation will overflow + + + // Subtraction + let _n = 1u8 - 5; //~ ERROR: arithmetic operation will overflow + let _n = &(1u8 - 5); //~ ERROR: arithmetic operation will overflow + + let _n = 1u16 - 5; //~ ERROR: arithmetic operation will overflow + let _n = &(1u16 - 5); //~ ERROR: arithmetic operation will overflow + + let _n = 1u32 - 5; //~ ERROR: arithmetic operation will overflow + let _n = &(1u32 - 5); //~ ERROR: arithmetic operation will overflow + + let _n = 1u64 - 5 ; //~ ERROR: arithmetic operation will overflow + let _n = &(1u64 - 5); //~ ERROR: arithmetic operation will overflow + + let _n = 1u128 - 5 ; //~ ERROR: arithmetic operation will overflow + let _n = &(1u128 - 5); //~ ERROR: arithmetic operation will overflow + + let _n = -5i8 - i8::MAX; //~ ERROR: arithmetic operation will overflow + let _n = &(-5i8 - i8::MAX); //~ ERROR: arithmetic operation will overflow + + let _n = -5i16 - i16::MAX; //~ ERROR: arithmetic operation will overflow + let _n = &(-5i16 - i16::MAX); //~ ERROR: arithmetic operation will overflow + + let _n = -5i32 - i32::MAX; //~ ERROR: arithmetic operation will overflow + let _n = &(-5i32 - i32::MAX); //~ ERROR: arithmetic operation will overflow + + let _n = -5i64 - i64::MAX; //~ ERROR: arithmetic operation will overflow + let _n = &(-5i64 - i64::MAX); //~ ERROR: arithmetic operation will overflow + + let _n = -5i128 - i128::MAX; //~ ERROR: arithmetic operation will overflow + let _n = &(-5i128 - i128::MAX); //~ ERROR: arithmetic operation will overflow + + let _n = -5isize - isize::MAX; //~ ERROR: arithmetic operation will overflow + let _n = &(-5isize - isize::MAX); //~ ERROR: arithmetic operation will overflow + + let _n = 1usize - 5; //~ ERROR: arithmetic operation will overflow + let _n = &(1usize - 5); //~ ERROR: arithmetic operation will overflow + + + // Multiplication + let _n = u8::MAX * 5; //~ ERROR: arithmetic operation will overflow + let _n = &(u8::MAX * 5); //~ ERROR: arithmetic operation will overflow + + let _n = u16::MAX * 5; //~ ERROR: arithmetic operation will overflow + let _n = &(u16::MAX * 5); //~ ERROR: arithmetic operation will overflow + + let _n = u32::MAX * 5; //~ ERROR: arithmetic operation will overflow + let _n = &(u32::MAX * 5); //~ ERROR: arithmetic operation will overflow + + let _n = u64::MAX * 5; //~ ERROR: arithmetic operation will overflow + let _n = &(u64::MAX * 5); //~ ERROR: arithmetic operation will overflow + + let _n = u128::MAX * 5; //~ ERROR: arithmetic operation will overflow + let _n = &(u128::MAX * 5); //~ ERROR: arithmetic operation will overflow + + let _n = i8::MAX * i8::MAX; //~ ERROR: arithmetic operation will overflow + let _n = &(i8::MAX * i8::MAX); //~ ERROR: arithmetic operation will overflow + + let _n = i16::MAX * 5; //~ ERROR: arithmetic operation will overflow + let _n = &(i16::MAX * 5); //~ ERROR: arithmetic operation will overflow + + let _n = i32::MAX * 5; //~ ERROR: arithmetic operation will overflow + let _n = &(i32::MAX * 5); //~ ERROR: arithmetic operation will overflow + + let _n = i64::MAX * 5; //~ ERROR: arithmetic operation will overflow + let _n = &(i64::MAX * 5); //~ ERROR: arithmetic operation will overflow + + let _n = i128::MAX * 5; //~ ERROR: arithmetic operation will overflow + let _n = &(i128::MAX * 5); //~ ERROR: arithmetic operation will overflow + + let _n = isize::MAX * 5; //~ ERROR: arithmetic operation will overflow + let _n = &(isize::MAX * 5); //~ ERROR: arithmetic operation will overflow + + let _n = usize::MAX * 5; //~ ERROR: arithmetic operation will overflow + let _n = &(usize::MAX * 5); //~ ERROR: arithmetic operation will overflow + + + // Division + let _n = 1u8 / 0; //~ ERROR: this operation will panic at runtime + let _n = &(1u8 / 0); //~ ERROR: this operation will panic at runtime + + let _n = 1u16 / 0; //~ ERROR: this operation will panic at runtime + let _n = &(1u16 / 0); //~ ERROR: this operation will panic at runtime + + let _n = 1u32 / 0; //~ ERROR: this operation will panic at runtime + let _n = &(1u32 / 0); //~ ERROR: this operation will panic at runtime + + let _n = 1u64 / 0; //~ ERROR: this operation will panic at runtime + let _n = &(1u64 / 0); //~ ERROR: this operation will panic at runtime + + let _n = 1u128 / 0; //~ ERROR: this operation will panic at runtime + let _n = &(1u128 / 0); //~ ERROR: this operation will panic at runtime + + let _n = 1i8 / 0; //~ ERROR: this operation will panic at runtime + let _n = &(1i8 / 0); //~ ERROR: this operation will panic at runtime + + let _n = 1i16 / 0; //~ ERROR: this operation will panic at runtime + let _n = &(1i16 / 0); //~ ERROR: this operation will panic at runtime + + let _n = 1i32 / 0; //~ ERROR: this operation will panic at runtime + let _n = &(1i32 / 0); //~ ERROR: this operation will panic at runtime + + let _n = 1i64 / 0; //~ ERROR: this operation will panic at runtime + let _n = &(1i64 / 0); //~ ERROR: this operation will panic at runtime + + let _n = 1i128 / 0; //~ ERROR: this operation will panic at runtime + let _n = &(1i128 / 0); //~ ERROR: this operation will panic at runtime + + let _n = 1isize / 0; //~ ERROR: this operation will panic at runtime + let _n = &(1isize / 0); //~ ERROR: this operation will panic at runtime + + let _n = 1usize / 0; //~ ERROR: this operation will panic at runtime + let _n = &(1usize / 0); //~ ERROR: this operation will panic at runtime + + + // Modulus + let _n = 1u8 % 0; //~ ERROR: this operation will panic at runtime + let _n = &(1u8 % 0); //~ ERROR: this operation will panic at runtime + + let _n = 1u16 % 0; //~ ERROR: this operation will panic at runtime + let _n = &(1u16 % 0); //~ ERROR: this operation will panic at runtime + + let _n = 1u32 % 0; //~ ERROR: this operation will panic at runtime + let _n = &(1u32 % 0); //~ ERROR: this operation will panic at runtime + + let _n = 1u64 % 0; //~ ERROR: this operation will panic at runtime + let _n = &(1u64 % 0); //~ ERROR: this operation will panic at runtime + + let _n = 1u128 % 0; //~ ERROR: this operation will panic at runtime + let _n = &(1u128 % 0); //~ ERROR: this operation will panic at runtime + + let _n = 1i8 % 0; //~ ERROR: this operation will panic at runtime + let _n = &(1i8 % 0); //~ ERROR: this operation will panic at runtime + + let _n = 1i16 % 0; //~ ERROR: this operation will panic at runtime + let _n = &(1i16 % 0); //~ ERROR: this operation will panic at runtime + + let _n = 1i32 % 0; //~ ERROR: this operation will panic at runtime + let _n = &(1i32 % 0); //~ ERROR: this operation will panic at runtime + + let _n = 1i64 % 0; //~ ERROR: this operation will panic at runtime + let _n = &(1i64 % 0); //~ ERROR: this operation will panic at runtime + + let _n = 1i128 % 0; //~ ERROR: this operation will panic at runtime + let _n = &(1i128 % 0); //~ ERROR: this operation will panic at runtime + + let _n = 1isize % 0; //~ ERROR: this operation will panic at runtime + let _n = &(1isize % 0); //~ ERROR: this operation will panic at runtime + + let _n = 1usize % 0; //~ ERROR: this operation will panic at runtime + let _n = &(1usize % 0); //~ ERROR: this operation will panic at runtime + + + // Out of bounds access + let _n = [1, 2, 3][4]; //~ ERROR: this operation will panic at runtime + let _n = &([1, 2, 3][4]); //~ ERROR: this operation will panic at runtime +} diff --git a/tests/ui/numbers-arithmetic/promoted_overflow_opt.rs b/tests/ui/numbers-arithmetic/promoted_overflow_opt.rs deleted file mode 100644 index 7004c9a366509..0000000000000 --- a/tests/ui/numbers-arithmetic/promoted_overflow_opt.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ run-pass - -//@ compile-flags: -O - -fn main() { - let x = &(0u32 - 1); - assert_eq!(*x, u32::MAX) -}