Skip to content

Commit 7c372cd

Browse files
committed
Auto merge of rust-lang#102091 - RalfJung:const_err, r=oli-obk
make const_err a hard error This lint has been deny-by-default with future incompat wording since [Rust 1.51](rust-lang#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#71800 Fixes rust-lang#100114
2 parents 6819e85 + e91746e commit 7c372cd

File tree

7 files changed

+12
-7
lines changed

7 files changed

+12
-7
lines changed

clippy_lints/src/indexing_slicing.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ declare_clippy_lint! {
1919
///
2020
/// ### Example
2121
/// ```rust,no_run
22-
/// # #![allow(const_err)]
2322
/// let x = [1, 2, 3, 4];
2423
///
2524
/// x[9];

tests/ui/crashes/ice-9463.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(arithmetic_overflow, const_err)]
1+
#![deny(arithmetic_overflow)]
22
fn main() {
33
let _x = -1_i32 >> -1;
44
let _y = 1u32 >> 10000000000000u32;

tests/ui/crashes/ice-9463.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | let _x = -1_i32 >> -1;
77
note: the lint level is defined here
88
--> $DIR/ice-9463.rs:1:9
99
|
10-
LL | #![deny(arithmetic_overflow, const_err)]
10+
LL | #![deny(arithmetic_overflow)]
1111
| ^^^^^^^^^^^^^^^^^^^
1212

1313
error: this arithmetic operation will overflow

tests/ui/indexing_slicing_index.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// We also check the out_of_bounds_indexing lint here, because it lints similar things and
44
// we want to avoid false positives.
55
#![warn(clippy::out_of_bounds_indexing)]
6-
#![allow(const_err, unconditional_panic, clippy::no_effect, clippy::unnecessary_operation)]
6+
#![allow(unconditional_panic, clippy::no_effect, clippy::unnecessary_operation)]
77

88
const ARR: [i32; 2] = [1, 2];
99
const REF: &i32 = &ARR[idx()]; // Ok, should not produce stderr.

tests/ui/indexing_slicing_index.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ LL | v[M];
5959
|
6060
= help: consider using `.get(n)` or `.get_mut(n)` instead
6161

62-
error: aborting due to 8 previous errors
62+
error[E0080]: evaluation of constant value failed
63+
--> $DIR/indexing_slicing_index.rs:10:24
64+
|
65+
LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts.
66+
| ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4
67+
68+
error: aborting due to 9 previous errors
6369

6470
For more information about this error, try `rustc --explain E0080`.

tests/ui/out_of_bounds_indexing/issue-3102.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(clippy::out_of_bounds_indexing)]
2-
#![allow(clippy::no_effect, const_err)]
2+
#![allow(clippy::no_effect)]
33

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

tests/ui/out_of_bounds_indexing/simple.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(clippy::out_of_bounds_indexing)]
2-
#![allow(clippy::no_effect, clippy::unnecessary_operation, const_err)]
2+
#![allow(clippy::no_effect, clippy::unnecessary_operation)]
33

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

0 commit comments

Comments
 (0)