Skip to content

Commit

Permalink
Auto merge of #102091 - RalfJung:const_err, r=oli-obk
Browse files Browse the repository at this point in the history
make const_err a hard error

This lint has been deny-by-default with future incompat wording since [Rust 1.51](rust-lang/rust#80394) and the stable release of this week starts showing it in cargo's future compat reports. I can't wait to finally get rid of at least some of the mess in our const-err-reporting-code. ;)

r? `@oli-obk`
Fixes rust-lang/rust#71800
Fixes rust-lang/rust#100114
  • Loading branch information
bors committed Oct 7, 2022
2 parents 6819e85 + e91746e commit 7c372cd
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 7 deletions.
1 change: 0 additions & 1 deletion clippy_lints/src/indexing_slicing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ declare_clippy_lint! {
///
/// ### Example
/// ```rust,no_run
/// # #![allow(const_err)]
/// let x = [1, 2, 3, 4];
///
/// x[9];
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/crashes/ice-9463.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![deny(arithmetic_overflow, const_err)]
#![deny(arithmetic_overflow)]
fn main() {
let _x = -1_i32 >> -1;
let _y = 1u32 >> 10000000000000u32;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/crashes/ice-9463.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | let _x = -1_i32 >> -1;
note: the lint level is defined here
--> $DIR/ice-9463.rs:1:9
|
LL | #![deny(arithmetic_overflow, const_err)]
LL | #![deny(arithmetic_overflow)]
| ^^^^^^^^^^^^^^^^^^^

error: this arithmetic operation will overflow
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/indexing_slicing_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// We also check the out_of_bounds_indexing lint here, because it lints similar things and
// we want to avoid false positives.
#![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 REF: &i32 = &ARR[idx()]; // Ok, should not produce stderr.
Expand Down
8 changes: 7 additions & 1 deletion tests/ui/indexing_slicing_index.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ LL | v[M];
|
= 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`.
2 changes: 1 addition & 1 deletion tests/ui/out_of_bounds_indexing/issue-3102.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![warn(clippy::out_of_bounds_indexing)]
#![allow(clippy::no_effect, const_err)]
#![allow(clippy::no_effect)]

fn main() {
let x = [1, 2, 3, 4];
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/out_of_bounds_indexing/simple.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![warn(clippy::out_of_bounds_indexing)]
#![allow(clippy::no_effect, clippy::unnecessary_operation, const_err)]
#![allow(clippy::no_effect, clippy::unnecessary_operation)]

fn main() {
let x = [1, 2, 3, 4];
Expand Down

0 comments on commit 7c372cd

Please sign in to comment.