make const_err a hard error
This commit is contained in:
parent
09a554db25
commit
e91746ed82
7 changed files with 12 additions and 7 deletions
|
@ -19,7 +19,6 @@ declare_clippy_lint! {
|
||||||
///
|
///
|
||||||
/// ### Example
|
/// ### Example
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # #![allow(const_err)]
|
|
||||||
/// let x = [1, 2, 3, 4];
|
/// let x = [1, 2, 3, 4];
|
||||||
///
|
///
|
||||||
/// x[9];
|
/// x[9];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#![deny(arithmetic_overflow, const_err)]
|
#![deny(arithmetic_overflow)]
|
||||||
fn main() {
|
fn main() {
|
||||||
let _x = -1_i32 >> -1;
|
let _x = -1_i32 >> -1;
|
||||||
let _y = 1u32 >> 10000000000000u32;
|
let _y = 1u32 >> 10000000000000u32;
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | let _x = -1_i32 >> -1;
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/ice-9463.rs:1:9
|
--> $DIR/ice-9463.rs:1:9
|
||||||
|
|
|
|
||||||
LL | #![deny(arithmetic_overflow, const_err)]
|
LL | #![deny(arithmetic_overflow)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: this arithmetic operation will overflow
|
error: this arithmetic operation will overflow
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// We also check the out_of_bounds_indexing lint here, because it lints similar things and
|
// We also check the out_of_bounds_indexing lint here, because it lints similar things and
|
||||||
// we want to avoid false positives.
|
// we want to avoid false positives.
|
||||||
#![warn(clippy::out_of_bounds_indexing)]
|
#![warn(clippy::out_of_bounds_indexing)]
|
||||||
#![allow(const_err, unconditional_panic, clippy::no_effect, clippy::unnecessary_operation)]
|
#![allow(unconditional_panic, clippy::no_effect, clippy::unnecessary_operation)]
|
||||||
|
|
||||||
const ARR: [i32; 2] = [1, 2];
|
const ARR: [i32; 2] = [1, 2];
|
||||||
const REF: &i32 = &ARR[idx()]; // Ok, should not produce stderr.
|
const REF: &i32 = &ARR[idx()]; // Ok, should not produce stderr.
|
||||||
|
|
|
@ -59,6 +59,12 @@ LL | v[M];
|
||||||
|
|
|
|
||||||
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
||||||
|
|
||||||
error: aborting due to 8 previous errors
|
error[E0080]: evaluation of constant value failed
|
||||||
|
--> $DIR/indexing_slicing_index.rs:10:24
|
||||||
|
|
|
||||||
|
LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts.
|
||||||
|
| ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4
|
||||||
|
|
||||||
|
error: aborting due to 9 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#![warn(clippy::out_of_bounds_indexing)]
|
#![warn(clippy::out_of_bounds_indexing)]
|
||||||
#![allow(clippy::no_effect, const_err)]
|
#![allow(clippy::no_effect)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = [1, 2, 3, 4];
|
let x = [1, 2, 3, 4];
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#![warn(clippy::out_of_bounds_indexing)]
|
#![warn(clippy::out_of_bounds_indexing)]
|
||||||
#![allow(clippy::no_effect, clippy::unnecessary_operation, const_err)]
|
#![allow(clippy::no_effect, clippy::unnecessary_operation)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = [1, 2, 3, 4];
|
let x = [1, 2, 3, 4];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue