diff --git a/tests/ui/lint/lint-overflowing-ops.noopt.stderr b/tests/ui/lint/lint-overflowing-ops.noopt.stderr index 265868ccc6108..f89ee8569c66f 100644 --- a/tests/ui/lint/lint-overflowing-ops.noopt.stderr +++ b/tests/ui/lint/lint-overflowing-ops.noopt.stderr @@ -13,81 +13,81 @@ LL | #![deny(arithmetic_overflow)] error: this arithmetic operation will overflow --> $DIR/lint-overflowing-ops.rs:226:15 | -LL | let _n = &(-i8::MIN); - | ^^^^^^^^^^ attempt to negate `i8::MIN`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:223: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:220: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:217:15 + --> $DIR/lint-overflowing-ops.rs:223: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:214:15 + --> $DIR/lint-overflowing-ops.rs:220: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:211:15 + --> $DIR/lint-overflowing-ops.rs:217: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:208:15 + --> $DIR/lint-overflowing-ops.rs:214: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:205:15 + --> $DIR/lint-overflowing-ops.rs:211: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:202:15 + --> $DIR/lint-overflowing-ops.rs:208: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:205: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:199:15 + --> $DIR/lint-overflowing-ops.rs:202: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:196:15 + --> $DIR/lint-overflowing-ops.rs:199: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:193:15 + --> $DIR/lint-overflowing-ops.rs:196: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:190:15 + --> $DIR/lint-overflowing-ops.rs:193: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:188:15 + | +LL | let _n = &(-i8::MIN); + | ^^^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + error: this arithmetic operation will overflow --> $DIR/lint-overflowing-ops.rs:185:15 | @@ -701,83 +701,83 @@ 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:189:14 + --> $DIR/lint-overflowing-ops.rs:187:14 + | +LL | let _n = -i8::MIN; + | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:192: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:192:14 + --> $DIR/lint-overflowing-ops.rs:195: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:195:14 + --> $DIR/lint-overflowing-ops.rs:198: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:198:14 + --> $DIR/lint-overflowing-ops.rs:201: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:201:14 + --> $DIR/lint-overflowing-ops.rs:204: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:204:14 + --> $DIR/lint-overflowing-ops.rs:207:14 + | +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:210: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:207:14 + --> $DIR/lint-overflowing-ops.rs:213: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:210:14 + --> $DIR/lint-overflowing-ops.rs:216: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:213:14 + --> $DIR/lint-overflowing-ops.rs:219: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:216:14 + --> $DIR/lint-overflowing-ops.rs:222: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:219:14 + --> $DIR/lint-overflowing-ops.rs:225: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:222:14 - | -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:225:14 - | -LL | let _n = -i8::MIN; - | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow - error: this operation will panic at runtime --> $DIR/lint-overflowing-ops.rs:230:14 | @@ -843,386 +843,531 @@ LL | let _n = &(1u128 / 0); error: this operation will panic at runtime --> $DIR/lint-overflowing-ops.rs:245: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:246: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:248: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:246:15 + --> $DIR/lint-overflowing-ops.rs:249: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:248:14 + --> $DIR/lint-overflowing-ops.rs:250:14 + | +LL | let _n = i8::MIN / -1; + | ^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:251:15 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:251:15 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:251:14 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:254: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:249:15 + --> $DIR/lint-overflowing-ops.rs:255: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:251:14 + --> $DIR/lint-overflowing-ops.rs:256:14 + | +LL | let _n = i16::MIN / -1; + | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:257:15 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:257:15 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:257:14 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:260: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:252:15 + --> $DIR/lint-overflowing-ops.rs:261: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:254:14 + --> $DIR/lint-overflowing-ops.rs:262:14 + | +LL | let _n = i32::MIN / -1; + | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:263:15 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:263:15 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:263:14 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:266: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:255:15 + --> $DIR/lint-overflowing-ops.rs:267: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:257:14 + --> $DIR/lint-overflowing-ops.rs:268:14 + | +LL | let _n = i64::MIN / -1; + | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:269:15 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:269:15 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:269:14 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:272: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:258:15 + --> $DIR/lint-overflowing-ops.rs:273: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:260:14 + --> $DIR/lint-overflowing-ops.rs:274:14 + | +LL | let _n = i128::MIN / -1; + | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:275:15 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:275:15 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:275:14 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:278: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:261:15 + --> $DIR/lint-overflowing-ops.rs:279: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:263:14 + --> $DIR/lint-overflowing-ops.rs:280:14 | -LL | let _n = 1usize / 0; - | ^^^^^^^^^^ attempt to divide `1_usize` by zero +LL | let _n = isize::MIN / -1; + | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:264:15 + --> $DIR/lint-overflowing-ops.rs:281:15 | -LL | let _n = &(1usize / 0); - | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:281:15 + | +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:281:14 + | +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:268:14 + --> $DIR/lint-overflowing-ops.rs:286: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:269:15 + --> $DIR/lint-overflowing-ops.rs:287: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:271:14 + --> $DIR/lint-overflowing-ops.rs:289: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:272:15 + --> $DIR/lint-overflowing-ops.rs:290: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:274:14 + --> $DIR/lint-overflowing-ops.rs:292: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:275:15 + --> $DIR/lint-overflowing-ops.rs:293: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:277:14 + --> $DIR/lint-overflowing-ops.rs:295: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:278:15 + --> $DIR/lint-overflowing-ops.rs:296: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:280:14 + --> $DIR/lint-overflowing-ops.rs:298: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:281:15 + --> $DIR/lint-overflowing-ops.rs:299: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:283:14 + --> $DIR/lint-overflowing-ops.rs:301:14 | -LL | let _n = 1i8 % 0; - | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero +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:284:15 + --> $DIR/lint-overflowing-ops.rs:302:15 | -LL | let _n = &(1i8 % 0); - | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero +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:286:14 + --> $DIR/lint-overflowing-ops.rs:304:14 | -LL | let _n = 1i16 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero +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:287:15 + --> $DIR/lint-overflowing-ops.rs:305:15 | -LL | let _n = &(1i16 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero +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:289:14 + --> $DIR/lint-overflowing-ops.rs:306:14 | -LL | let _n = 1i32 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero +LL | let _n = i8::MIN % -1; + | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:290:15 + --> $DIR/lint-overflowing-ops.rs:307:15 | -LL | let _n = &(1i32 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:292:14 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:307:15 | -LL | let _n = 1i64 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:293:15 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:307:14 | -LL | let _n = &(1i64 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:295:14 + --> $DIR/lint-overflowing-ops.rs:310:14 | -LL | let _n = 1i128 % 0; - | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero +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:296:15 + --> $DIR/lint-overflowing-ops.rs:311:15 | -LL | let _n = &(1i128 % 0); - | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero +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:298:14 + --> $DIR/lint-overflowing-ops.rs:312:14 | -LL | let _n = 1isize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +LL | let _n = i16::MIN % -1; + | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:299:15 + --> $DIR/lint-overflowing-ops.rs:313:15 | -LL | let _n = &(1isize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:301:14 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:313:15 | -LL | let _n = 1usize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:302:15 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:313:14 | -LL | let _n = &(1usize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:306:14 + --> $DIR/lint-overflowing-ops.rs:316:14 | -LL | let _n = [1, 2, 3][4]; - | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 +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:307:15 + --> $DIR/lint-overflowing-ops.rs:317:15 | -LL | let _n = &([1, 2, 3][4]); - | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 +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:311:36 + --> $DIR/lint-overflowing-ops.rs:318:14 | -LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow +LL | let _n = i32::MIN % -1; + | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:313:36 + --> $DIR/lint-overflowing-ops.rs:319:15 | -LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:315:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:319:15 | -LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:317:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:319:14 | -LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:319:36 + --> $DIR/lint-overflowing-ops.rs:322:14 | -LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow +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:321:36 + --> $DIR/lint-overflowing-ops.rs:323:15 | -LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow +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:323:36 + --> $DIR/lint-overflowing-ops.rs:324:14 | -LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); - | ^^^^^^^^^^ attempt to divide `1_isize` by zero +LL | let _n = i64::MIN % -1; + | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:325:36 + --> $DIR/lint-overflowing-ops.rs:325:15 | -LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); - | ^^^^^^^ attempt to divide `1_i8` by zero +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:327:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:325:15 | -LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); - | ^^^^^^^^ attempt to divide `1_i16` by zero +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:329:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:325:14 | -LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); - | ^^^^^^^^ attempt to divide `1_i32` by zero +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:331:36 + --> $DIR/lint-overflowing-ops.rs:328:14 | -LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); - | ^^^^^^^^ attempt to divide `1_i64` by zero +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:333:36 + --> $DIR/lint-overflowing-ops.rs:329:15 | -LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); - | ^^^^^^^^^ attempt to divide `1_i128` by zero +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:335:36 + --> $DIR/lint-overflowing-ops.rs:330:14 | -LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow +LL | let _n = i128::MIN % -1; + | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:337:36 + --> $DIR/lint-overflowing-ops.rs:331:15 | -LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:339:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:331:15 | -LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:341:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:331:14 | -LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:343:36 + --> $DIR/lint-overflowing-ops.rs:334:14 | -LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow +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:345:36 + --> $DIR/lint-overflowing-ops.rs:335:15 | -LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow +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:347:36 + --> $DIR/lint-overflowing-ops.rs:336:14 | -LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +LL | let _n = isize::MIN % -1; + | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:349:36 + --> $DIR/lint-overflowing-ops.rs:337:15 | -LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); - | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:351:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:337:15 | -LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); - | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:353:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:337:14 | -LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); - | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:355:36 + --> $DIR/lint-overflowing-ops.rs:341:14 | -LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); - | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero +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:357:36 + --> $DIR/lint-overflowing-ops.rs:342:15 | -LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); - | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero +LL | let _n = &([1, 2, 3][4]); + | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 -error: aborting due to 203 previous errors +error: aborting due to 215 previous errors +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/lint/lint-overflowing-ops.opt.stderr b/tests/ui/lint/lint-overflowing-ops.opt.stderr index 265868ccc6108..7ac5c4e0d76ff 100644 --- a/tests/ui/lint/lint-overflowing-ops.opt.stderr +++ b/tests/ui/lint/lint-overflowing-ops.opt.stderr @@ -13,81 +13,81 @@ LL | #![deny(arithmetic_overflow)] error: this arithmetic operation will overflow --> $DIR/lint-overflowing-ops.rs:226:15 | -LL | let _n = &(-i8::MIN); - | ^^^^^^^^^^ attempt to negate `i8::MIN`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:223: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:220: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:217:15 + --> $DIR/lint-overflowing-ops.rs:223: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:214:15 + --> $DIR/lint-overflowing-ops.rs:220: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:211:15 + --> $DIR/lint-overflowing-ops.rs:217: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:208:15 + --> $DIR/lint-overflowing-ops.rs:214: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:205:15 + --> $DIR/lint-overflowing-ops.rs:211: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:202:15 + --> $DIR/lint-overflowing-ops.rs:208: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:205: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:199:15 + --> $DIR/lint-overflowing-ops.rs:202: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:196:15 + --> $DIR/lint-overflowing-ops.rs:199: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:193:15 + --> $DIR/lint-overflowing-ops.rs:196: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:190:15 + --> $DIR/lint-overflowing-ops.rs:193: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:188:15 + | +LL | let _n = &(-i8::MIN); + | ^^^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + error: this arithmetic operation will overflow --> $DIR/lint-overflowing-ops.rs:185:15 | @@ -701,83 +701,83 @@ 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:189:14 + --> $DIR/lint-overflowing-ops.rs:187:14 + | +LL | let _n = -i8::MIN; + | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:192: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:192:14 + --> $DIR/lint-overflowing-ops.rs:195: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:195:14 + --> $DIR/lint-overflowing-ops.rs:198: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:198:14 + --> $DIR/lint-overflowing-ops.rs:201: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:201:14 + --> $DIR/lint-overflowing-ops.rs:204: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:204:14 + --> $DIR/lint-overflowing-ops.rs:207:14 + | +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:210: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:207:14 + --> $DIR/lint-overflowing-ops.rs:213: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:210:14 + --> $DIR/lint-overflowing-ops.rs:216: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:213:14 + --> $DIR/lint-overflowing-ops.rs:219: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:216:14 + --> $DIR/lint-overflowing-ops.rs:222: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:219:14 + --> $DIR/lint-overflowing-ops.rs:225: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:222:14 - | -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:225:14 - | -LL | let _n = -i8::MIN; - | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow - error: this operation will panic at runtime --> $DIR/lint-overflowing-ops.rs:230:14 | @@ -843,386 +843,627 @@ LL | let _n = &(1u128 / 0); error: this operation will panic at runtime --> $DIR/lint-overflowing-ops.rs:245: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:246: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:248: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:246:15 + --> $DIR/lint-overflowing-ops.rs:249: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:248:14 + --> $DIR/lint-overflowing-ops.rs:250:14 + | +LL | let _n = i8::MIN / -1; + | ^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:251:15 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:251:15 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:251:14 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^^ + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:251:14 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:254: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:249:15 + --> $DIR/lint-overflowing-ops.rs:255: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:251:14 + --> $DIR/lint-overflowing-ops.rs:256:14 + | +LL | let _n = i16::MIN / -1; + | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:257:15 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:257:15 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:257:14 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^^ + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:257:14 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:260: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:252:15 + --> $DIR/lint-overflowing-ops.rs:261: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:254:14 + --> $DIR/lint-overflowing-ops.rs:262:14 + | +LL | let _n = i32::MIN / -1; + | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:263:15 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:263:15 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:263:14 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^^ + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:263:14 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:266: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:255:15 + --> $DIR/lint-overflowing-ops.rs:267: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:257:14 + --> $DIR/lint-overflowing-ops.rs:268:14 + | +LL | let _n = i64::MIN / -1; + | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:269:15 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:269:15 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:269:14 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^^ + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:269:14 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:272: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:258:15 + --> $DIR/lint-overflowing-ops.rs:273: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:260:14 + --> $DIR/lint-overflowing-ops.rs:274:14 + | +LL | let _n = i128::MIN / -1; + | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:275:15 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:275:15 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:275:14 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^^ + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:275:14 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:278: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:261:15 + --> $DIR/lint-overflowing-ops.rs:279: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:263:14 + --> $DIR/lint-overflowing-ops.rs:280:14 | -LL | let _n = 1usize / 0; - | ^^^^^^^^^^ attempt to divide `1_usize` by zero +LL | let _n = isize::MIN / -1; + | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:264:15 + --> $DIR/lint-overflowing-ops.rs:281:15 | -LL | let _n = &(1usize / 0); - | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:281:15 + | +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:281:14 + | +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^^ + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:281:14 + | +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:268:14 + --> $DIR/lint-overflowing-ops.rs:286: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:269:15 + --> $DIR/lint-overflowing-ops.rs:287: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:271:14 + --> $DIR/lint-overflowing-ops.rs:289: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:272:15 + --> $DIR/lint-overflowing-ops.rs:290: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:274:14 + --> $DIR/lint-overflowing-ops.rs:292: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:275:15 + --> $DIR/lint-overflowing-ops.rs:293: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:277:14 + --> $DIR/lint-overflowing-ops.rs:295: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:278:15 + --> $DIR/lint-overflowing-ops.rs:296: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:280:14 + --> $DIR/lint-overflowing-ops.rs:298: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:281:15 + --> $DIR/lint-overflowing-ops.rs:299: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:283:14 + --> $DIR/lint-overflowing-ops.rs:301: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:302: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:304: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:284:15 + --> $DIR/lint-overflowing-ops.rs:305: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:286:14 + --> $DIR/lint-overflowing-ops.rs:306:14 + | +LL | let _n = i8::MIN % -1; + | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:307:15 + | +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:307:15 + | +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:307:14 + | +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^^ + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:307:14 + | +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:310: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:287:15 + --> $DIR/lint-overflowing-ops.rs:311: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:289:14 + --> $DIR/lint-overflowing-ops.rs:312:14 | -LL | let _n = 1i32 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero +LL | let _n = i16::MIN % -1; + | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:290:15 + --> $DIR/lint-overflowing-ops.rs:313:15 | -LL | let _n = &(1i32 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:292:14 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:313:15 | -LL | let _n = 1i64 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:293:15 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:313:14 | -LL | let _n = &(1i64 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^^ -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:295:14 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:313: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:296:15 +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^^ | -LL | let _n = &(1i128 % 0); - | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:298:14 + --> $DIR/lint-overflowing-ops.rs:316:14 | -LL | let _n = 1isize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +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:299:15 + --> $DIR/lint-overflowing-ops.rs:317:15 | -LL | let _n = &(1isize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +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:301:14 + --> $DIR/lint-overflowing-ops.rs:318:14 | -LL | let _n = 1usize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero +LL | let _n = i32::MIN % -1; + | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:302:15 + --> $DIR/lint-overflowing-ops.rs:319:15 | -LL | let _n = &(1usize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:306:14 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:319:15 | -LL | let _n = [1, 2, 3][4]; - | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:307:15 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:319:14 | -LL | let _n = &([1, 2, 3][4]); - | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^^ -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:311:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:319:14 + | +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^^ | -LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:313:36 + --> $DIR/lint-overflowing-ops.rs:322:14 | -LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow +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:315:36 + --> $DIR/lint-overflowing-ops.rs:323:15 | -LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow +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:317:36 + --> $DIR/lint-overflowing-ops.rs:324:14 | -LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow +LL | let _n = i64::MIN % -1; + | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:319:36 + --> $DIR/lint-overflowing-ops.rs:325:15 | -LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:321:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:325:15 | -LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:323:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:325:14 | -LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); - | ^^^^^^^^^^ attempt to divide `1_isize` by zero +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^^ -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:325:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:325:14 + | +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^^ | -LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); - | ^^^^^^^ attempt to divide `1_i8` by zero + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:327:36 + --> $DIR/lint-overflowing-ops.rs:328:14 | -LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); - | ^^^^^^^^ attempt to divide `1_i16` by zero +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:329:36 + --> $DIR/lint-overflowing-ops.rs:329:15 | -LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); - | ^^^^^^^^ attempt to divide `1_i32` by zero +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:331:36 + --> $DIR/lint-overflowing-ops.rs:330:14 | -LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); - | ^^^^^^^^ attempt to divide `1_i64` by zero +LL | let _n = i128::MIN % -1; + | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:333:36 + --> $DIR/lint-overflowing-ops.rs:331:15 | -LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); - | ^^^^^^^^^ attempt to divide `1_i128` by zero +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:335:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:331:15 | -LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:337:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:331:14 | -LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^^ -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:339:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:331:14 + | +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^^ | -LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:341:36 + --> $DIR/lint-overflowing-ops.rs:334:14 | -LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow +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:343:36 + --> $DIR/lint-overflowing-ops.rs:335:15 | -LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow +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:345:36 + --> $DIR/lint-overflowing-ops.rs:336:14 | -LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow +LL | let _n = isize::MIN % -1; + | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:347:36 + --> $DIR/lint-overflowing-ops.rs:337:15 | -LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:349:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:337:15 | -LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); - | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:351:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:337:14 | -LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); - | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^^ -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:353:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:337:14 | -LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); - | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:355:36 + --> $DIR/lint-overflowing-ops.rs:341:14 | -LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); - | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero +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:357:36 + --> $DIR/lint-overflowing-ops.rs:342:15 | -LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); - | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero +LL | let _n = &([1, 2, 3][4]); + | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 -error: aborting due to 203 previous errors +error: aborting due to 215 previous errors +For more information about this error, try `rustc --explain E0080`. 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 index 265868ccc6108..f89ee8569c66f 100644 --- a/tests/ui/lint/lint-overflowing-ops.opt_with_overflow_checks.stderr +++ b/tests/ui/lint/lint-overflowing-ops.opt_with_overflow_checks.stderr @@ -13,81 +13,81 @@ LL | #![deny(arithmetic_overflow)] error: this arithmetic operation will overflow --> $DIR/lint-overflowing-ops.rs:226:15 | -LL | let _n = &(-i8::MIN); - | ^^^^^^^^^^ attempt to negate `i8::MIN`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:223: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:220: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:217:15 + --> $DIR/lint-overflowing-ops.rs:223: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:214:15 + --> $DIR/lint-overflowing-ops.rs:220: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:211:15 + --> $DIR/lint-overflowing-ops.rs:217: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:208:15 + --> $DIR/lint-overflowing-ops.rs:214: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:205:15 + --> $DIR/lint-overflowing-ops.rs:211: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:202:15 + --> $DIR/lint-overflowing-ops.rs:208: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:205: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:199:15 + --> $DIR/lint-overflowing-ops.rs:202: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:196:15 + --> $DIR/lint-overflowing-ops.rs:199: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:193:15 + --> $DIR/lint-overflowing-ops.rs:196: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:190:15 + --> $DIR/lint-overflowing-ops.rs:193: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:188:15 + | +LL | let _n = &(-i8::MIN); + | ^^^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + error: this arithmetic operation will overflow --> $DIR/lint-overflowing-ops.rs:185:15 | @@ -701,83 +701,83 @@ 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:189:14 + --> $DIR/lint-overflowing-ops.rs:187:14 + | +LL | let _n = -i8::MIN; + | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:192: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:192:14 + --> $DIR/lint-overflowing-ops.rs:195: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:195:14 + --> $DIR/lint-overflowing-ops.rs:198: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:198:14 + --> $DIR/lint-overflowing-ops.rs:201: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:201:14 + --> $DIR/lint-overflowing-ops.rs:204: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:204:14 + --> $DIR/lint-overflowing-ops.rs:207:14 + | +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:210: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:207:14 + --> $DIR/lint-overflowing-ops.rs:213: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:210:14 + --> $DIR/lint-overflowing-ops.rs:216: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:213:14 + --> $DIR/lint-overflowing-ops.rs:219: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:216:14 + --> $DIR/lint-overflowing-ops.rs:222: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:219:14 + --> $DIR/lint-overflowing-ops.rs:225: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:222:14 - | -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:225:14 - | -LL | let _n = -i8::MIN; - | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow - error: this operation will panic at runtime --> $DIR/lint-overflowing-ops.rs:230:14 | @@ -843,386 +843,531 @@ LL | let _n = &(1u128 / 0); error: this operation will panic at runtime --> $DIR/lint-overflowing-ops.rs:245: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:246: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:248: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:246:15 + --> $DIR/lint-overflowing-ops.rs:249: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:248:14 + --> $DIR/lint-overflowing-ops.rs:250:14 + | +LL | let _n = i8::MIN / -1; + | ^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:251:15 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:251:15 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:251:14 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:254: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:249:15 + --> $DIR/lint-overflowing-ops.rs:255: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:251:14 + --> $DIR/lint-overflowing-ops.rs:256:14 + | +LL | let _n = i16::MIN / -1; + | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:257:15 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:257:15 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:257:14 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:260: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:252:15 + --> $DIR/lint-overflowing-ops.rs:261: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:254:14 + --> $DIR/lint-overflowing-ops.rs:262:14 + | +LL | let _n = i32::MIN / -1; + | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:263:15 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:263:15 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:263:14 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:266: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:255:15 + --> $DIR/lint-overflowing-ops.rs:267: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:257:14 + --> $DIR/lint-overflowing-ops.rs:268:14 + | +LL | let _n = i64::MIN / -1; + | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:269:15 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:269:15 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:269:14 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:272: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:258:15 + --> $DIR/lint-overflowing-ops.rs:273: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:260:14 + --> $DIR/lint-overflowing-ops.rs:274:14 + | +LL | let _n = i128::MIN / -1; + | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:275:15 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:275:15 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:275:14 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:278: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:261:15 + --> $DIR/lint-overflowing-ops.rs:279: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:263:14 + --> $DIR/lint-overflowing-ops.rs:280:14 | -LL | let _n = 1usize / 0; - | ^^^^^^^^^^ attempt to divide `1_usize` by zero +LL | let _n = isize::MIN / -1; + | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:264:15 + --> $DIR/lint-overflowing-ops.rs:281:15 | -LL | let _n = &(1usize / 0); - | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:281:15 + | +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:281:14 + | +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:268:14 + --> $DIR/lint-overflowing-ops.rs:286: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:269:15 + --> $DIR/lint-overflowing-ops.rs:287: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:271:14 + --> $DIR/lint-overflowing-ops.rs:289: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:272:15 + --> $DIR/lint-overflowing-ops.rs:290: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:274:14 + --> $DIR/lint-overflowing-ops.rs:292: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:275:15 + --> $DIR/lint-overflowing-ops.rs:293: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:277:14 + --> $DIR/lint-overflowing-ops.rs:295: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:278:15 + --> $DIR/lint-overflowing-ops.rs:296: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:280:14 + --> $DIR/lint-overflowing-ops.rs:298: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:281:15 + --> $DIR/lint-overflowing-ops.rs:299: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:283:14 + --> $DIR/lint-overflowing-ops.rs:301:14 | -LL | let _n = 1i8 % 0; - | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero +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:284:15 + --> $DIR/lint-overflowing-ops.rs:302:15 | -LL | let _n = &(1i8 % 0); - | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero +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:286:14 + --> $DIR/lint-overflowing-ops.rs:304:14 | -LL | let _n = 1i16 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero +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:287:15 + --> $DIR/lint-overflowing-ops.rs:305:15 | -LL | let _n = &(1i16 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero +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:289:14 + --> $DIR/lint-overflowing-ops.rs:306:14 | -LL | let _n = 1i32 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero +LL | let _n = i8::MIN % -1; + | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:290:15 + --> $DIR/lint-overflowing-ops.rs:307:15 | -LL | let _n = &(1i32 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:292:14 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:307:15 | -LL | let _n = 1i64 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:293:15 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:307:14 | -LL | let _n = &(1i64 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:295:14 + --> $DIR/lint-overflowing-ops.rs:310:14 | -LL | let _n = 1i128 % 0; - | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero +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:296:15 + --> $DIR/lint-overflowing-ops.rs:311:15 | -LL | let _n = &(1i128 % 0); - | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero +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:298:14 + --> $DIR/lint-overflowing-ops.rs:312:14 | -LL | let _n = 1isize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +LL | let _n = i16::MIN % -1; + | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:299:15 + --> $DIR/lint-overflowing-ops.rs:313:15 | -LL | let _n = &(1isize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:301:14 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:313:15 | -LL | let _n = 1usize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:302:15 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:313:14 | -LL | let _n = &(1usize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:306:14 + --> $DIR/lint-overflowing-ops.rs:316:14 | -LL | let _n = [1, 2, 3][4]; - | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 +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:307:15 + --> $DIR/lint-overflowing-ops.rs:317:15 | -LL | let _n = &([1, 2, 3][4]); - | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 +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:311:36 + --> $DIR/lint-overflowing-ops.rs:318:14 | -LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow +LL | let _n = i32::MIN % -1; + | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:313:36 + --> $DIR/lint-overflowing-ops.rs:319:15 | -LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:315:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:319:15 | -LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:317:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:319:14 | -LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:319:36 + --> $DIR/lint-overflowing-ops.rs:322:14 | -LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow +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:321:36 + --> $DIR/lint-overflowing-ops.rs:323:15 | -LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow +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:323:36 + --> $DIR/lint-overflowing-ops.rs:324:14 | -LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); - | ^^^^^^^^^^ attempt to divide `1_isize` by zero +LL | let _n = i64::MIN % -1; + | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:325:36 + --> $DIR/lint-overflowing-ops.rs:325:15 | -LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); - | ^^^^^^^ attempt to divide `1_i8` by zero +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:327:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:325:15 | -LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); - | ^^^^^^^^ attempt to divide `1_i16` by zero +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:329:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:325:14 | -LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); - | ^^^^^^^^ attempt to divide `1_i32` by zero +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:331:36 + --> $DIR/lint-overflowing-ops.rs:328:14 | -LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); - | ^^^^^^^^ attempt to divide `1_i64` by zero +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:333:36 + --> $DIR/lint-overflowing-ops.rs:329:15 | -LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); - | ^^^^^^^^^ attempt to divide `1_i128` by zero +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:335:36 + --> $DIR/lint-overflowing-ops.rs:330:14 | -LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow +LL | let _n = i128::MIN % -1; + | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:337:36 + --> $DIR/lint-overflowing-ops.rs:331:15 | -LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:339:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:331:15 | -LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:341:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:331:14 | -LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:343:36 + --> $DIR/lint-overflowing-ops.rs:334:14 | -LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow +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:345:36 + --> $DIR/lint-overflowing-ops.rs:335:15 | -LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow +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:347:36 + --> $DIR/lint-overflowing-ops.rs:336:14 | -LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +LL | let _n = isize::MIN % -1; + | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:349:36 + --> $DIR/lint-overflowing-ops.rs:337:15 | -LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); - | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:351:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:337:15 | -LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); - | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:353:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:337:14 | -LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); - | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:355:36 + --> $DIR/lint-overflowing-ops.rs:341:14 | -LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); - | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero +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:357:36 + --> $DIR/lint-overflowing-ops.rs:342:15 | -LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); - | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero +LL | let _n = &([1, 2, 3][4]); + | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 -error: aborting due to 203 previous errors +error: aborting due to 215 previous errors +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/lint/lint-overflowing-ops.rs b/tests/ui/lint/lint-overflowing-ops.rs index 5305677d166c1..4ef99f6c5fa18 100644 --- a/tests/ui/lint/lint-overflowing-ops.rs +++ b/tests/ui/lint/lint-overflowing-ops.rs @@ -184,6 +184,9 @@ fn main() { let _n = 1usize - 5; //~ ERROR: arithmetic operation will overflow let _n = &(1usize - 5); //~ ERROR: arithmetic operation will overflow + let _n = -i8::MIN; //~ ERROR this arithmetic operation will overflow + let _n = &(-i8::MIN); //~ ERROR this arithmetic operation will overflow + // Multiplication let _n = u8::MAX * 5; //~ ERROR: arithmetic operation will overflow @@ -201,6 +204,9 @@ fn main() { let _n = u128::MAX * 5; //~ ERROR: arithmetic operation will overflow let _n = &(u128::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 + let _n = i8::MAX * i8::MAX; //~ ERROR: arithmetic operation will overflow let _n = &(i8::MAX * i8::MAX); //~ ERROR: arithmetic operation will overflow @@ -219,12 +225,6 @@ fn main() { 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 - - let _n = -i8::MIN; //~ ERROR this arithmetic operation will overflow - let _n = &(-i8::MIN); //~ ERROR this arithmetic operation will overflow - // Division let _n = 1u8 / 0; //~ ERROR: this operation will panic at runtime @@ -242,26 +242,44 @@ fn main() { let _n = 1u128 / 0; //~ ERROR: this operation will panic at runtime let _n = &(1u128 / 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 + let _n = 1i8 / 0; //~ ERROR: this operation will panic at runtime let _n = &(1i8 / 0); //~ ERROR: this operation will panic at runtime + let _n = i8::MIN / -1; //~ ERROR: this operation will panic at runtime + let _n = &(i8::MIN / -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed let _n = 1i16 / 0; //~ ERROR: this operation will panic at runtime let _n = &(1i16 / 0); //~ ERROR: this operation will panic at runtime + let _n = i16::MIN / -1; //~ ERROR: this operation will panic at runtime + let _n = &(i16::MIN / -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed let _n = 1i32 / 0; //~ ERROR: this operation will panic at runtime let _n = &(1i32 / 0); //~ ERROR: this operation will panic at runtime + let _n = i32::MIN / -1; //~ ERROR: this operation will panic at runtime + let _n = &(i32::MIN / -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed let _n = 1i64 / 0; //~ ERROR: this operation will panic at runtime let _n = &(1i64 / 0); //~ ERROR: this operation will panic at runtime + let _n = i64::MIN / -1; //~ ERROR: this operation will panic at runtime + let _n = &(i64::MIN / -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed let _n = 1i128 / 0; //~ ERROR: this operation will panic at runtime let _n = &(1i128 / 0); //~ ERROR: this operation will panic at runtime + let _n = i128::MIN / -1; //~ ERROR: this operation will panic at runtime + let _n = &(i128::MIN / -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed 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 + let _n = isize::MIN / -1; //~ ERROR: this operation will panic at runtime + let _n = &(isize::MIN / -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed // Modulus @@ -280,80 +298,46 @@ fn main() { let _n = 1u128 % 0; //~ ERROR: this operation will panic at runtime let _n = &(1u128 % 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 + let _n = 1i8 % 0; //~ ERROR: this operation will panic at runtime let _n = &(1i8 % 0); //~ ERROR: this operation will panic at runtime + let _n = i8::MIN % -1; //~ ERROR: this operation will panic at runtime + let _n = &(i8::MIN % -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed let _n = 1i16 % 0; //~ ERROR: this operation will panic at runtime let _n = &(1i16 % 0); //~ ERROR: this operation will panic at runtime + let _n = i16::MIN % -1; //~ ERROR: this operation will panic at runtime + let _n = &(i16::MIN % -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed let _n = 1i32 % 0; //~ ERROR: this operation will panic at runtime let _n = &(1i32 % 0); //~ ERROR: this operation will panic at runtime + let _n = i32::MIN % -1; //~ ERROR: this operation will panic at runtime + let _n = &(i32::MIN % -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed let _n = 1i64 % 0; //~ ERROR: this operation will panic at runtime let _n = &(1i64 % 0); //~ ERROR: this operation will panic at runtime + let _n = i64::MIN % -1; //~ ERROR: this operation will panic at runtime + let _n = &(i64::MIN % -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed let _n = 1i128 % 0; //~ ERROR: this operation will panic at runtime let _n = &(1i128 % 0); //~ ERROR: this operation will panic at runtime + let _n = i128::MIN % -1; //~ ERROR: this operation will panic at runtime + let _n = &(i128::MIN % -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed 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 - + let _n = isize::MIN % -1; //~ ERROR: this operation will panic at runtime + let _n = &(isize::MIN % -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed // 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 - - - // issue-8460-const - assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); - //~^ ERROR operation will panic }