Skip to content

Commit 1788af3

Browse files
committed
Make the const_err lint deny-by-default
1 parent 41707d8 commit 1788af3

28 files changed

+95
-58
lines changed

src/librustc/lint/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ declare_lint! {
2727

2828
declare_lint! {
2929
pub CONST_ERR,
30-
Warn,
30+
Deny,
3131
"constant evaluation detected erroneous expression"
3232
}
3333

src/test/compile-fail/array_const_index-0.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010

1111
const A: &'static [i32] = &[];
1212
const B: i32 = (&A)[1];
13-
//~^ ERROR constant evaluation error
14-
//~| index out of bounds: the len is 0 but the index is 1
15-
//~| WARN this constant cannot be used
13+
//~^ index out of bounds: the len is 0 but the index is 1
14+
//~| ERROR this constant cannot be used
1615

1716
fn main() {
1817
let _ = B;

src/test/compile-fail/array_const_index-1.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010

1111
const A: [i32; 0] = [];
1212
const B: i32 = A[1];
13-
//~^ ERROR constant evaluation error
14-
//~| index out of bounds: the len is 0 but the index is 1
15-
//~| WARN this constant cannot be used
13+
//~^ index out of bounds: the len is 0 but the index is 1
14+
//~| ERROR this constant cannot be used
1615

1716
fn main() {
1817
let _ = B;

src/test/compile-fail/const-slice-oob.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212

1313
const FOO: &'static[u32] = &[1, 2, 3];
1414
const BAR: u32 = FOO[5];
15-
//~^ ERROR constant evaluation error [E0080]
16-
//~| index out of bounds: the len is 3 but the index is 5
17-
//~| WARN this constant cannot be used
15+
//~^ index out of bounds: the len is 3 but the index is 5
16+
//~| ERROR this constant cannot be used
1817

1918
fn main() {
2019
let _ = BAR;

src/test/compile-fail/eval-enum.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ enum Test {
1212
DivZero = 1/0,
1313
//~^ attempt to divide by zero
1414
//~| ERROR constant evaluation error
15-
//~| WARN constant evaluation error
15+
//~| ERROR constant evaluation error
1616
RemZero = 1%0,
1717
//~^ attempt to calculate the remainder with a divisor of zero
1818
//~| ERROR constant evaluation error
19-
//~| WARN constant evaluation error
19+
//~| ERROR constant evaluation error
2020
}
2121

2222
fn main() {}

src/test/incremental/warnings-reemitted.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// compile-pass
1414

1515
#![allow(warnings)]
16+
#![warn(const_err)]
1617

1718
fn main() {
1819
255u8 + 1; //~ WARNING this expression will panic at run-time

src/test/run-fail/overflowing-add.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
// error-pattern:thread 'main' panicked at 'attempt to add with overflow'
1212
// compile-flags: -C debug-assertions
1313

14+
#![allow(const_err)]
15+
1416
fn main() {
1517
let _x = 200u8 + 200u8 + 200u8;
1618
}

src/test/run-fail/overflowing-mul.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
// error-pattern:thread 'main' panicked at 'attempt to multiply with overflow'
1212
// compile-flags: -C debug-assertions
1313

14+
#![allow(const_err)]
15+
1416
fn main() {
1517
let x = 200u8 * 4;
1618
}

src/test/run-fail/overflowing-neg.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
// error-pattern:thread 'main' panicked at 'attempt to negate with overflow'
1212
// compile-flags: -C debug-assertions
1313

14+
#![allow(const_err)]
15+
1416
fn main() {
1517
let _x = -std::i8::MIN;
1618
}

src/test/run-fail/overflowing-sub.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
// error-pattern:thread 'main' panicked at 'attempt to subtract with overflow'
1212
// compile-flags: -C debug-assertions
1313

14+
#![allow(const_err)]
15+
1416
fn main() {
1517
let _x = 42u8 - (42u8 + 1);
1618
}

0 commit comments

Comments
 (0)