Auto merge of #76754 - varkor:diagnostic-cleanup-ii, r=ecstatic-morse
Clean up diagnostics for arithmetic operation errors Plus a small tweak to a range pattern error message.
This commit is contained in:
commit
4d52dc4790
119 changed files with 452 additions and 447 deletions
|
|
@ -2,7 +2,7 @@ warning: this operation will panic at runtime
|
|||
--> $DIR/array-literal-index-oob.rs:7:8
|
||||
|
|
||||
LL | &{ [1, 2, 3][4] };
|
||||
| ^^^^^^^^^^^^ index out of bounds: the len is 3 but the index is 4
|
||||
| ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/array-literal-index-oob.rs:4:20
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ warning: any use of this value will cause an error
|
|||
LL | const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()];
|
||||
| -----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| index out of bounds: the len is 1 but the index is 4
|
||||
| index out of bounds: the length is 1 but the index is 4
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/assoc_const_generic_impl.rs:3:9
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ const BAR: usize = FOO[5]; // no error, because the error below occurs before re
|
|||
|
||||
const BLUB: [u32; FOO[4]] = [5, 6];
|
||||
//~^ ERROR evaluation of constant value failed [E0080]
|
||||
//~| index out of bounds: the len is 3 but the index is 4
|
||||
//~| index out of bounds: the length is 3 but the index is 4
|
||||
|
||||
fn main() {
|
||||
let _ = BAR;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
|
|||
--> $DIR/const-array-oob.rs:6:19
|
||||
|
|
||||
LL | const BLUB: [u32; FOO[4]] = [5, 6];
|
||||
| ^^^^^^ index out of bounds: the len is 3 but the index is 4
|
||||
| ^^^^^^ index out of bounds: the length is 3 but the index is 4
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error: any use of this value will cause an error
|
|||
LL | pub const A: i8 = -std::i8::MIN;
|
||||
| ------------------^^^^^^^^^^^^^-
|
||||
| |
|
||||
| attempt to negate i8::MIN which would overflow
|
||||
| attempt to negate `i8::MIN`, which would overflow
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/const-err-early.rs:1:9
|
||||
|
|
@ -18,7 +18,7 @@ error: any use of this value will cause an error
|
|||
LL | pub const B: u8 = 200u8 + 200u8;
|
||||
| ------------------^^^^^^^^^^^^^-
|
||||
| |
|
||||
| attempt to compute `200_u8 + 200_u8` which would overflow
|
||||
| attempt to compute `200_u8 + 200_u8`, which would overflow
|
||||
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-err-early.rs:5:19
|
||||
|
|
@ -26,7 +26,7 @@ error: any use of this value will cause an error
|
|||
LL | pub const C: u8 = 200u8 * 4;
|
||||
| ------------------^^^^^^^^^-
|
||||
| |
|
||||
| attempt to compute `200_u8 * 4_u8` which would overflow
|
||||
| attempt to compute `200_u8 * 4_u8`, which would overflow
|
||||
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-err-early.rs:6:19
|
||||
|
|
@ -34,7 +34,7 @@ error: any use of this value will cause an error
|
|||
LL | pub const D: u8 = 42u8 - (42u8 + 1);
|
||||
| ------------------^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| attempt to compute `42_u8 - 43_u8` which would overflow
|
||||
| attempt to compute `42_u8 - 43_u8`, which would overflow
|
||||
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-err-early.rs:7:19
|
||||
|
|
@ -42,7 +42,7 @@ error: any use of this value will cause an error
|
|||
LL | pub const E: u8 = [5u8][1];
|
||||
| ------------------^^^^^^^^-
|
||||
| |
|
||||
| index out of bounds: the len is 1 but the index is 1
|
||||
| index out of bounds: the length is 1 but the index is 1
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error: any use of this value will cause an error
|
|||
LL | pub const A: i8 = -std::i8::MIN;
|
||||
| ------------------^^^^^^^^^^^^^-
|
||||
| |
|
||||
| attempt to negate i8::MIN which would overflow
|
||||
| attempt to negate `i8::MIN`, which would overflow
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/const-err-multi.rs:1:9
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ warning: any use of this value will cause an error
|
|||
LL | const FOO: u8 = [5u8][1];
|
||||
| ----------------^^^^^^^^-
|
||||
| |
|
||||
| index out of bounds: the len is 1 but the index is 1
|
||||
| index out of bounds: the length is 1 but the index is 1
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/const-err.rs:5:9
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: this arithmetic operation will overflow
|
|||
--> $DIR/const-err2.rs:19:13
|
||||
|
|
||||
LL | let a = -std::i8::MIN;
|
||||
| ^^^^^^^^^^^^^ attempt to negate i8::MIN which would overflow
|
||||
| ^^^^^^^^^^^^^ attempt to negate `i8::MIN`, which would overflow
|
||||
|
|
||||
= note: `#[deny(arithmetic_overflow)]` on by default
|
||||
|
||||
|
|
@ -10,37 +10,37 @@ error: this arithmetic operation will overflow
|
|||
--> $DIR/const-err2.rs:21:18
|
||||
|
|
||||
LL | let a_i128 = -std::i128::MIN;
|
||||
| ^^^^^^^^^^^^^^^ attempt to negate i128::MIN which would overflow
|
||||
| ^^^^^^^^^^^^^^^ attempt to negate `i128::MIN`, which would overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
--> $DIR/const-err2.rs:23:13
|
||||
|
|
||||
LL | let b = 200u8 + 200u8 + 200u8;
|
||||
| ^^^^^^^^^^^^^ attempt to compute `200_u8 + 200_u8` which would overflow
|
||||
| ^^^^^^^^^^^^^ attempt to compute `200_u8 + 200_u8`, which would overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
--> $DIR/const-err2.rs:25:18
|
||||
|
|
||||
LL | let b_i128 = std::i128::MIN - std::i128::MAX;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN - i128::MAX` which would overflow
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN - i128::MAX`, which would overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
--> $DIR/const-err2.rs:27:13
|
||||
|
|
||||
LL | let c = 200u8 * 4;
|
||||
| ^^^^^^^^^ attempt to compute `200_u8 * 4_u8` which would overflow
|
||||
| ^^^^^^^^^ attempt to compute `200_u8 * 4_u8`, which would overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
--> $DIR/const-err2.rs:29:13
|
||||
|
|
||||
LL | let d = 42u8 - (42u8 + 1);
|
||||
| ^^^^^^^^^^^^^^^^^ attempt to compute `42_u8 - 43_u8` which would overflow
|
||||
| ^^^^^^^^^^^^^^^^^ attempt to compute `42_u8 - 43_u8`, which would overflow
|
||||
|
||||
error: this operation will panic at runtime
|
||||
--> $DIR/const-err2.rs:31:14
|
||||
|
|
||||
LL | let _e = [5u8][1];
|
||||
| ^^^^^^^^ index out of bounds: the len is 1 but the index is 1
|
||||
| ^^^^^^^^ index out of bounds: the length is 1 but the index is 1
|
||||
|
|
||||
= note: `#[deny(unconditional_panic)]` on by default
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: this arithmetic operation will overflow
|
|||
--> $DIR/const-err2.rs:19:13
|
||||
|
|
||||
LL | let a = -std::i8::MIN;
|
||||
| ^^^^^^^^^^^^^ attempt to negate i8::MIN which would overflow
|
||||
| ^^^^^^^^^^^^^ attempt to negate `i8::MIN`, which would overflow
|
||||
|
|
||||
= note: `#[deny(arithmetic_overflow)]` on by default
|
||||
|
||||
|
|
@ -10,37 +10,37 @@ error: this arithmetic operation will overflow
|
|||
--> $DIR/const-err2.rs:21:18
|
||||
|
|
||||
LL | let a_i128 = -std::i128::MIN;
|
||||
| ^^^^^^^^^^^^^^^ attempt to negate i128::MIN which would overflow
|
||||
| ^^^^^^^^^^^^^^^ attempt to negate `i128::MIN`, which would overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
--> $DIR/const-err2.rs:23:13
|
||||
|
|
||||
LL | let b = 200u8 + 200u8 + 200u8;
|
||||
| ^^^^^^^^^^^^^ attempt to compute `200_u8 + 200_u8` which would overflow
|
||||
| ^^^^^^^^^^^^^ attempt to compute `200_u8 + 200_u8`, which would overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
--> $DIR/const-err2.rs:25:18
|
||||
|
|
||||
LL | let b_i128 = std::i128::MIN - std::i128::MAX;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN - i128::MAX` which would overflow
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN - i128::MAX`, which would overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
--> $DIR/const-err2.rs:27:13
|
||||
|
|
||||
LL | let c = 200u8 * 4;
|
||||
| ^^^^^^^^^ attempt to compute `200_u8 * 4_u8` which would overflow
|
||||
| ^^^^^^^^^ attempt to compute `200_u8 * 4_u8`, which would overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
--> $DIR/const-err2.rs:29:13
|
||||
|
|
||||
LL | let d = 42u8 - (42u8 + 1);
|
||||
| ^^^^^^^^^^^^^^^^^ attempt to compute `42_u8 - 43_u8` which would overflow
|
||||
| ^^^^^^^^^^^^^^^^^ attempt to compute `42_u8 - 43_u8`, which would overflow
|
||||
|
||||
error: this operation will panic at runtime
|
||||
--> $DIR/const-err2.rs:31:14
|
||||
|
|
||||
LL | let _e = [5u8][1];
|
||||
| ^^^^^^^^ index out of bounds: the len is 1 but the index is 1
|
||||
| ^^^^^^^^ index out of bounds: the length is 1 but the index is 1
|
||||
|
|
||||
= note: `#[deny(unconditional_panic)]` on by default
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: this arithmetic operation will overflow
|
|||
--> $DIR/const-err2.rs:19:13
|
||||
|
|
||||
LL | let a = -std::i8::MIN;
|
||||
| ^^^^^^^^^^^^^ attempt to negate i8::MIN which would overflow
|
||||
| ^^^^^^^^^^^^^ attempt to negate `i8::MIN`, which would overflow
|
||||
|
|
||||
= note: `#[deny(arithmetic_overflow)]` on by default
|
||||
|
||||
|
|
@ -10,37 +10,37 @@ error: this arithmetic operation will overflow
|
|||
--> $DIR/const-err2.rs:21:18
|
||||
|
|
||||
LL | let a_i128 = -std::i128::MIN;
|
||||
| ^^^^^^^^^^^^^^^ attempt to negate i128::MIN which would overflow
|
||||
| ^^^^^^^^^^^^^^^ attempt to negate `i128::MIN`, which would overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
--> $DIR/const-err2.rs:23:13
|
||||
|
|
||||
LL | let b = 200u8 + 200u8 + 200u8;
|
||||
| ^^^^^^^^^^^^^ attempt to compute `200_u8 + 200_u8` which would overflow
|
||||
| ^^^^^^^^^^^^^ attempt to compute `200_u8 + 200_u8`, which would overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
--> $DIR/const-err2.rs:25:18
|
||||
|
|
||||
LL | let b_i128 = std::i128::MIN - std::i128::MAX;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN - i128::MAX` which would overflow
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN - i128::MAX`, which would overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
--> $DIR/const-err2.rs:27:13
|
||||
|
|
||||
LL | let c = 200u8 * 4;
|
||||
| ^^^^^^^^^ attempt to compute `200_u8 * 4_u8` which would overflow
|
||||
| ^^^^^^^^^ attempt to compute `200_u8 * 4_u8`, which would overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
--> $DIR/const-err2.rs:29:13
|
||||
|
|
||||
LL | let d = 42u8 - (42u8 + 1);
|
||||
| ^^^^^^^^^^^^^^^^^ attempt to compute `42_u8 - 43_u8` which would overflow
|
||||
| ^^^^^^^^^^^^^^^^^ attempt to compute `42_u8 - 43_u8`, which would overflow
|
||||
|
||||
error: this operation will panic at runtime
|
||||
--> $DIR/const-err2.rs:31:14
|
||||
|
|
||||
LL | let _e = [5u8][1];
|
||||
| ^^^^^^^^ index out of bounds: the len is 1 but the index is 1
|
||||
| ^^^^^^^^ index out of bounds: the length is 1 but the index is 1
|
||||
|
|
||||
= note: `#[deny(unconditional_panic)]` on by default
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ warning: any use of this value will cause an error
|
|||
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
|
||||
| ------------------^^^^^---------------------------
|
||||
| |
|
||||
| attempt to compute `5_u32 - 6_u32` which would overflow
|
||||
| attempt to compute `5_u32 - 6_u32`, which would overflow
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/conditional_array_execution.rs:3:9
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
|
|||
--> $DIR/const-eval-overflow-3.rs:20:11
|
||||
|
|
||||
LL | = [0; (i8::MAX + 1) as usize];
|
||||
| ^^^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8` which would overflow
|
||||
| ^^^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
|
|||
--> $DIR/const-eval-overflow-4.rs:13:13
|
||||
|
|
||||
LL | : [u32; (i8::MAX as i8 + 1i8) as usize]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8` which would overflow
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error: any use of this value will cause an error
|
|||
LL | / const VALS_I8: (i8,) =
|
||||
LL | | (
|
||||
LL | | i8::MIN - 1,
|
||||
| | ^^^^^^^^^^^ attempt to compute `i8::MIN - 1_i8` which would overflow
|
||||
| | ^^^^^^^^^^^ attempt to compute `i8::MIN - 1_i8`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
|
||||
|
|
@ -20,7 +20,7 @@ error: any use of this value will cause an error
|
|||
LL | / const VALS_I16: (i16,) =
|
||||
LL | | (
|
||||
LL | | i16::MIN - 1,
|
||||
| | ^^^^^^^^^^^^ attempt to compute `i16::MIN - 1_i16` which would overflow
|
||||
| | ^^^^^^^^^^^^ attempt to compute `i16::MIN - 1_i16`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ error: any use of this value will cause an error
|
|||
LL | / const VALS_I32: (i32,) =
|
||||
LL | | (
|
||||
LL | | i32::MIN - 1,
|
||||
| | ^^^^^^^^^^^^ attempt to compute `i32::MIN - 1_i32` which would overflow
|
||||
| | ^^^^^^^^^^^^ attempt to compute `i32::MIN - 1_i32`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ error: any use of this value will cause an error
|
|||
LL | / const VALS_I64: (i64,) =
|
||||
LL | | (
|
||||
LL | | i64::MIN - 1,
|
||||
| | ^^^^^^^^^^^^ attempt to compute `i64::MIN - 1_i64` which would overflow
|
||||
| | ^^^^^^^^^^^^ attempt to compute `i64::MIN - 1_i64`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ error: any use of this value will cause an error
|
|||
LL | / const VALS_U8: (u8,) =
|
||||
LL | | (
|
||||
LL | | u8::MIN - 1,
|
||||
| | ^^^^^^^^^^^ attempt to compute `0_u8 - 1_u8` which would overflow
|
||||
| | ^^^^^^^^^^^ attempt to compute `0_u8 - 1_u8`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ error: any use of this value will cause an error
|
|||
|
|
||||
LL | / const VALS_U16: (u16,) = (
|
||||
LL | | u16::MIN - 1,
|
||||
| | ^^^^^^^^^^^^ attempt to compute `0_u16 - 1_u16` which would overflow
|
||||
| | ^^^^^^^^^^^^ attempt to compute `0_u16 - 1_u16`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ error: any use of this value will cause an error
|
|||
|
|
||||
LL | / const VALS_U32: (u32,) = (
|
||||
LL | | u32::MIN - 1,
|
||||
| | ^^^^^^^^^^^^ attempt to compute `0_u32 - 1_u32` which would overflow
|
||||
| | ^^^^^^^^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ error: any use of this value will cause an error
|
|||
LL | / const VALS_U64: (u64,) =
|
||||
LL | | (
|
||||
LL | | u64::MIN - 1,
|
||||
| | ^^^^^^^^^^^^ attempt to compute `0_u64 - 1_u64` which would overflow
|
||||
| | ^^^^^^^^^^^^ attempt to compute `0_u64 - 1_u64`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error: any use of this value will cause an error
|
|||
LL | / const VALS_I8: (i8,) =
|
||||
LL | | (
|
||||
LL | | i8::MAX + 1,
|
||||
| | ^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8` which would overflow
|
||||
| | ^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
|
||||
|
|
@ -20,7 +20,7 @@ error: any use of this value will cause an error
|
|||
LL | / const VALS_I16: (i16,) =
|
||||
LL | | (
|
||||
LL | | i16::MAX + 1,
|
||||
| | ^^^^^^^^^^^^ attempt to compute `i16::MAX + 1_i16` which would overflow
|
||||
| | ^^^^^^^^^^^^ attempt to compute `i16::MAX + 1_i16`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ error: any use of this value will cause an error
|
|||
LL | / const VALS_I32: (i32,) =
|
||||
LL | | (
|
||||
LL | | i32::MAX + 1,
|
||||
| | ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32` which would overflow
|
||||
| | ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ error: any use of this value will cause an error
|
|||
LL | / const VALS_I64: (i64,) =
|
||||
LL | | (
|
||||
LL | | i64::MAX + 1,
|
||||
| | ^^^^^^^^^^^^ attempt to compute `i64::MAX + 1_i64` which would overflow
|
||||
| | ^^^^^^^^^^^^ attempt to compute `i64::MAX + 1_i64`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ error: any use of this value will cause an error
|
|||
LL | / const VALS_U8: (u8,) =
|
||||
LL | | (
|
||||
LL | | u8::MAX + 1,
|
||||
| | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8` which would overflow
|
||||
| | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ error: any use of this value will cause an error
|
|||
|
|
||||
LL | / const VALS_U16: (u16,) = (
|
||||
LL | | u16::MAX + 1,
|
||||
| | ^^^^^^^^^^^^ attempt to compute `u16::MAX + 1_u16` which would overflow
|
||||
| | ^^^^^^^^^^^^ attempt to compute `u16::MAX + 1_u16`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ error: any use of this value will cause an error
|
|||
|
|
||||
LL | / const VALS_U32: (u32,) = (
|
||||
LL | | u32::MAX + 1,
|
||||
| | ^^^^^^^^^^^^ attempt to compute `u32::MAX + 1_u32` which would overflow
|
||||
| | ^^^^^^^^^^^^ attempt to compute `u32::MAX + 1_u32`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ error: any use of this value will cause an error
|
|||
LL | / const VALS_U64: (u64,) =
|
||||
LL | | (
|
||||
LL | | u64::MAX + 1,
|
||||
| | ^^^^^^^^^^^^ attempt to compute `u64::MAX + 1_u64` which would overflow
|
||||
| | ^^^^^^^^^^^^ attempt to compute `u64::MAX + 1_u64`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error: any use of this value will cause an error
|
|||
LL | / const VALS_I8: (i8,) =
|
||||
LL | | (
|
||||
LL | | i8::MIN * 2,
|
||||
| | ^^^^^^^^^^^ attempt to compute `i8::MIN * 2_i8` which would overflow
|
||||
| | ^^^^^^^^^^^ attempt to compute `i8::MIN * 2_i8`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
|
||||
|
|
@ -20,7 +20,7 @@ error: any use of this value will cause an error
|
|||
LL | / const VALS_I16: (i16,) =
|
||||
LL | | (
|
||||
LL | | i16::MIN * 2,
|
||||
| | ^^^^^^^^^^^^ attempt to compute `i16::MIN * 2_i16` which would overflow
|
||||
| | ^^^^^^^^^^^^ attempt to compute `i16::MIN * 2_i16`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ error: any use of this value will cause an error
|
|||
LL | / const VALS_I32: (i32,) =
|
||||
LL | | (
|
||||
LL | | i32::MIN * 2,
|
||||
| | ^^^^^^^^^^^^ attempt to compute `i32::MIN * 2_i32` which would overflow
|
||||
| | ^^^^^^^^^^^^ attempt to compute `i32::MIN * 2_i32`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ error: any use of this value will cause an error
|
|||
LL | / const VALS_I64: (i64,) =
|
||||
LL | | (
|
||||
LL | | i64::MIN * 2,
|
||||
| | ^^^^^^^^^^^^ attempt to compute `i64::MIN * 2_i64` which would overflow
|
||||
| | ^^^^^^^^^^^^ attempt to compute `i64::MIN * 2_i64`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ error: any use of this value will cause an error
|
|||
LL | / const VALS_U8: (u8,) =
|
||||
LL | | (
|
||||
LL | | u8::MAX * 2,
|
||||
| | ^^^^^^^^^^^ attempt to compute `u8::MAX * 2_u8` which would overflow
|
||||
| | ^^^^^^^^^^^ attempt to compute `u8::MAX * 2_u8`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ error: any use of this value will cause an error
|
|||
|
|
||||
LL | / const VALS_U16: (u16,) = (
|
||||
LL | | u16::MAX * 2,
|
||||
| | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 2_u16` which would overflow
|
||||
| | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 2_u16`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ error: any use of this value will cause an error
|
|||
|
|
||||
LL | / const VALS_U32: (u32,) = (
|
||||
LL | | u32::MAX * 2,
|
||||
| | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 2_u32` which would overflow
|
||||
| | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 2_u32`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ error: any use of this value will cause an error
|
|||
LL | / const VALS_U64: (u64,) =
|
||||
LL | | (
|
||||
LL | | u64::MAX * 2,
|
||||
| | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 2_u64` which would overflow
|
||||
| | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 2_u64`, which would overflow
|
||||
LL | | );
|
||||
| |_______-
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ warning: this operation will panic at runtime
|
|||
--> $DIR/erroneous-const.rs:6:22
|
||||
|
|
||||
LL | const VOID: () = [()][2];
|
||||
| ^^^^^^^ index out of bounds: the len is 1 but the index is 2
|
||||
| ^^^^^^^ index out of bounds: the length is 1 but the index is 2
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/erroneous-const.rs:2:20
|
||||
|
|
@ -16,7 +16,7 @@ warning: any use of this value will cause an error
|
|||
LL | const VOID: () = [()][2];
|
||||
| -----------------^^^^^^^-
|
||||
| |
|
||||
| index out of bounds: the len is 1 but the index is 2
|
||||
| index out of bounds: the length is 1 but the index is 2
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/erroneous-const.rs:2:9
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ warning: any use of this value will cause an error
|
|||
LL | const VOID: ! = { let x = 0 * std::mem::size_of::<T>(); [][x] };
|
||||
| --------------------------------------------------------^^^^^---
|
||||
| |
|
||||
| index out of bounds: the len is 0 but the index is 0
|
||||
| index out of bounds: the length is 0 but the index is 0
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/index-out-of-bounds-never-type.rs:4:9
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0080]: could not evaluate static initializer
|
|||
--> $DIR/index_out_of_bounds.rs:1:19
|
||||
|
|
||||
LL | static FOO: i32 = [][0];
|
||||
| ^^^^^ index out of bounds: the len is 0 but the index is 0
|
||||
| ^^^^^ index out of bounds: the length is 0 but the index is 0
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: this operation will panic at runtime
|
|||
--> $DIR/index_out_of_bounds_propagated.rs:5:5
|
||||
|
|
||||
LL | array[1];
|
||||
| ^^^^^^^^ index out of bounds: the len is 1 but the index is 1
|
||||
| ^^^^^^^^ index out of bounds: the length is 1 but the index is 1
|
||||
|
|
||||
= note: `#[deny(unconditional_panic)]` on by default
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ warning: any use of this value will cause an error
|
|||
LL | const X: u32 = 0 - 1;
|
||||
| ---------------^^^^^-
|
||||
| |
|
||||
| attempt to compute `0_u32 - 1_u32` which would overflow
|
||||
| attempt to compute `0_u32 - 1_u32`, which would overflow
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-43197.rs:3:9
|
||||
|
|
@ -18,7 +18,7 @@ warning: any use of this value will cause an error
|
|||
LL | const Y: u32 = foo(0 - 1);
|
||||
| -------------------^^^^^--
|
||||
| |
|
||||
| attempt to compute `0_u32 - 1_u32` which would overflow
|
||||
| attempt to compute `0_u32 - 1_u32`, which would overflow
|
||||
|
||||
error[E0080]: evaluation of constant expression failed
|
||||
--> $DIR/issue-43197.rs:14:23
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error: any use of this value will cause an error
|
|||
LL | const BAR: usize = [5, 6, 7][T::BOO];
|
||||
| -------------------^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| index out of bounds: the len is 3 but the index is 42
|
||||
| index out of bounds: the length is 3 but the index is 42
|
||||
|
|
||||
= note: `#[deny(const_err)]` on by default
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error: any use of this value will cause an error
|
|||
LL | const MAX: u8 = A::MAX + B::MAX;
|
||||
| ----------------^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| attempt to compute `u8::MAX + u8::MAX` which would overflow
|
||||
| attempt to compute `u8::MAX + u8::MAX`, which would overflow
|
||||
|
|
||||
= note: `#[deny(const_err)]` on by default
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ warning: this arithmetic operation will overflow
|
|||
--> $DIR/promoted_errors.rs:12:20
|
||||
|
|
||||
LL | println!("{}", 0u32 - 1);
|
||||
| ^^^^^^^^ attempt to compute `0_u32 - 1_u32` which would overflow
|
||||
| ^^^^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/promoted_errors.rs:9:20
|
||||
|
|
@ -14,13 +14,13 @@ warning: this arithmetic operation will overflow
|
|||
--> $DIR/promoted_errors.rs:14:14
|
||||
|
|
||||
LL | let _x = 0u32 - 1;
|
||||
| ^^^^^^^^ attempt to compute `0_u32 - 1_u32` which would overflow
|
||||
| ^^^^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow
|
||||
|
||||
warning: this operation will panic at runtime
|
||||
--> $DIR/promoted_errors.rs:16:20
|
||||
|
|
||||
LL | println!("{}", 1 / (1 - 1));
|
||||
| ^^^^^^^^^^^ attempt to divide 1_i32 by zero
|
||||
| ^^^^^^^^^^^ attempt to divide `1_i32` by zero
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/promoted_errors.rs:9:41
|
||||
|
|
@ -50,13 +50,13 @@ warning: this operation will panic at runtime
|
|||
--> $DIR/promoted_errors.rs:20:14
|
||||
|
|
||||
LL | let _x = 1 / (1 - 1);
|
||||
| ^^^^^^^^^^^ attempt to divide 1_i32 by zero
|
||||
| ^^^^^^^^^^^ attempt to divide `1_i32` by zero
|
||||
|
||||
warning: this operation will panic at runtime
|
||||
--> $DIR/promoted_errors.rs:22:20
|
||||
|
|
||||
LL | println!("{}", 1 / (false as u32));
|
||||
| ^^^^^^^^^^^^^^^^^^ attempt to divide 1_u32 by zero
|
||||
| ^^^^^^^^^^^^^^^^^^ attempt to divide `1_u32` by zero
|
||||
|
||||
warning: reaching this expression at runtime will panic or abort
|
||||
--> $DIR/promoted_errors.rs:22:20
|
||||
|
|
@ -74,7 +74,7 @@ warning: this operation will panic at runtime
|
|||
--> $DIR/promoted_errors.rs:26:14
|
||||
|
|
||||
LL | let _x = 1 / (false as u32);
|
||||
| ^^^^^^^^^^^^^^^^^^ attempt to divide 1_u32 by zero
|
||||
| ^^^^^^^^^^^^^^^^^^ attempt to divide `1_u32` by zero
|
||||
|
||||
warning: 10 warnings emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ warning: this arithmetic operation will overflow
|
|||
--> $DIR/promoted_errors.rs:14:14
|
||||
|
|
||||
LL | let _x = 0u32 - 1;
|
||||
| ^^^^^^^^ attempt to compute `0_u32 - 1_u32` which would overflow
|
||||
| ^^^^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/promoted_errors.rs:9:20
|
||||
|
|
@ -14,7 +14,7 @@ warning: this operation will panic at runtime
|
|||
--> $DIR/promoted_errors.rs:16:20
|
||||
|
|
||||
LL | println!("{}", 1 / (1 - 1));
|
||||
| ^^^^^^^^^^^ attempt to divide 1_i32 by zero
|
||||
| ^^^^^^^^^^^ attempt to divide `1_i32` by zero
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/promoted_errors.rs:9:41
|
||||
|
|
@ -44,13 +44,13 @@ warning: this operation will panic at runtime
|
|||
--> $DIR/promoted_errors.rs:20:14
|
||||
|
|
||||
LL | let _x = 1 / (1 - 1);
|
||||
| ^^^^^^^^^^^ attempt to divide 1_i32 by zero
|
||||
| ^^^^^^^^^^^ attempt to divide `1_i32` by zero
|
||||
|
||||
warning: this operation will panic at runtime
|
||||
--> $DIR/promoted_errors.rs:22:20
|
||||
|
|
||||
LL | println!("{}", 1 / (false as u32));
|
||||
| ^^^^^^^^^^^^^^^^^^ attempt to divide 1_u32 by zero
|
||||
| ^^^^^^^^^^^^^^^^^^ attempt to divide `1_u32` by zero
|
||||
|
||||
warning: reaching this expression at runtime will panic or abort
|
||||
--> $DIR/promoted_errors.rs:22:20
|
||||
|
|
@ -68,7 +68,7 @@ warning: this operation will panic at runtime
|
|||
--> $DIR/promoted_errors.rs:26:14
|
||||
|
|
||||
LL | let _x = 1 / (false as u32);
|
||||
| ^^^^^^^^^^^^^^^^^^ attempt to divide 1_u32 by zero
|
||||
| ^^^^^^^^^^^^^^^^^^ attempt to divide `1_u32` by zero
|
||||
|
||||
warning: 9 warnings emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ warning: this arithmetic operation will overflow
|
|||
--> $DIR/promoted_errors.rs:12:20
|
||||
|
|
||||
LL | println!("{}", 0u32 - 1);
|
||||
| ^^^^^^^^ attempt to compute `0_u32 - 1_u32` which would overflow
|
||||
| ^^^^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/promoted_errors.rs:9:20
|
||||
|
|
@ -14,13 +14,13 @@ warning: this arithmetic operation will overflow
|
|||
--> $DIR/promoted_errors.rs:14:14
|
||||
|
|
||||
LL | let _x = 0u32 - 1;
|
||||
| ^^^^^^^^ attempt to compute `0_u32 - 1_u32` which would overflow
|
||||
| ^^^^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow
|
||||
|
||||
warning: this operation will panic at runtime
|
||||
--> $DIR/promoted_errors.rs:16:20
|
||||
|
|
||||
LL | println!("{}", 1 / (1 - 1));
|
||||
| ^^^^^^^^^^^ attempt to divide 1_i32 by zero
|
||||
| ^^^^^^^^^^^ attempt to divide `1_i32` by zero
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/promoted_errors.rs:9:41
|
||||
|
|
@ -50,13 +50,13 @@ warning: this operation will panic at runtime
|
|||
--> $DIR/promoted_errors.rs:20:14
|
||||
|
|
||||
LL | let _x = 1 / (1 - 1);
|
||||
| ^^^^^^^^^^^ attempt to divide 1_i32 by zero
|
||||
| ^^^^^^^^^^^ attempt to divide `1_i32` by zero
|
||||
|
||||
warning: this operation will panic at runtime
|
||||
--> $DIR/promoted_errors.rs:22:20
|
||||
|
|
||||
LL | println!("{}", 1 / (false as u32));
|
||||
| ^^^^^^^^^^^^^^^^^^ attempt to divide 1_u32 by zero
|
||||
| ^^^^^^^^^^^^^^^^^^ attempt to divide `1_u32` by zero
|
||||
|
||||
warning: reaching this expression at runtime will panic or abort
|
||||
--> $DIR/promoted_errors.rs:22:20
|
||||
|
|
@ -74,7 +74,7 @@ warning: this operation will panic at runtime
|
|||
--> $DIR/promoted_errors.rs:26:14
|
||||
|
|
||||
LL | let _x = 1 / (false as u32);
|
||||
| ^^^^^^^^^^^^^^^^^^ attempt to divide 1_u32 by zero
|
||||
| ^^^^^^^^^^^^^^^^^^ attempt to divide `1_u32` by zero
|
||||
|
||||
warning: 10 warnings emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ warning: any use of this value will cause an error
|
|||
LL | pub const Z: u32 = 0 - 1;
|
||||
| -------------------^^^^^-
|
||||
| |
|
||||
| attempt to compute `0_u32 - 1_u32` which would overflow
|
||||
| attempt to compute `0_u32 - 1_u32`, which would overflow
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/pub_const_err.rs:2:9
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ warning: any use of this value will cause an error
|
|||
LL | pub const Z: u32 = 0 - 1;
|
||||
| -------------------^^^^^-
|
||||
| |
|
||||
| attempt to compute `0_u32 - 1_u32` which would overflow
|
||||
| attempt to compute `0_u32 - 1_u32`, which would overflow
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/pub_const_err_bin.rs:2:9
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
|
|||
--> $DIR/shift_overflow.rs:3:9
|
||||
|
|
||||
LL | X = 1 << ((u32::MAX as u64) + 1),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to shift left by 4294967296_u64 which would overflow
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to shift left by `4294967296_u64`, which would overflow
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error: any use of this value will cause an error
|
|||
LL | const FOO: i32 = [][0];
|
||||
| -----------------^^^^^-
|
||||
| |
|
||||
| index out of bounds: the len is 0 but the index is 0
|
||||
| index out of bounds: the length is 0 but the index is 0
|
||||
|
|
||||
= note: `#[deny(const_err)]` on by default
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: any use of this value will cause an error
|
|||
--> $DIR/const-external-macro-const-err.rs:12:5
|
||||
|
|
||||
LL | static_assert!(2 + 2 == 5);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the len is 1 but the index is 1
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1
|
||||
|
|
||||
= note: `#[deny(const_err)]` on by default
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error: any use of this value will cause an error
|
|||
LL | const LEN: usize = ONE - TWO;
|
||||
| -------------------^^^^^^^^^-
|
||||
| |
|
||||
| attempt to compute `1_usize - 2_usize` which would overflow
|
||||
| attempt to compute `1_usize - 2_usize`, which would overflow
|
||||
|
|
||||
= note: `#[deny(const_err)]` on by default
|
||||
|
||||
|
|
|
|||
|
|
@ -7,5 +7,5 @@ const TWO: usize = 2;
|
|||
fn main() {
|
||||
let a: [i8; ONE - TWO] = unimplemented!();
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
//~| attempt to compute `1_usize - 2_usize` which would overflow
|
||||
//~| attempt to compute `1_usize - 2_usize`, which would overflow
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
|
|||
--> $DIR/const-len-underflow-subspans.rs:8:17
|
||||
|
|
||||
LL | let a: [i8; ONE - TWO] = unimplemented!();
|
||||
| ^^^^^^^^^ attempt to compute `1_usize - 2_usize` which would overflow
|
||||
| ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: this operation will panic at runtime
|
|||
--> $DIR/const-prop-ice.rs:4:5
|
||||
|
|
||||
LL | [0; 3][3u64 as usize];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the len is 3 but the index is 3
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 3
|
||||
|
|
||||
= note: `#[deny(unconditional_panic)]` on by default
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: this operation will panic at runtime
|
|||
--> $DIR/const-prop-ice2.rs:6:20
|
||||
|
|
||||
LL | println!("{}", xs[Enum::One as usize]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the len is 1 but the index is 1
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1
|
||||
|
|
||||
= note: `#[deny(unconditional_panic)]` on by default
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const FOO: &'static[u32] = &[1, 2, 3];
|
||||
const BAR: u32 = FOO[5];
|
||||
//~^ index out of bounds: the len is 3 but the index is 5
|
||||
//~^ index out of bounds: the length is 3 but the index is 5
|
||||
//~| ERROR any use of this value will cause an error
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error: any use of this value will cause an error
|
|||
LL | const BAR: u32 = FOO[5];
|
||||
| -----------------^^^^^^-
|
||||
| |
|
||||
| index out of bounds: the len is 3 but the index is 5
|
||||
| index out of bounds: the length is 3 but the index is 5
|
||||
|
|
||||
= note: `#[deny(const_err)]` on by default
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue