Skip to content

Commit 8477d35

Browse files
committed
make const_err a future incompat lint
1 parent d6a28a9 commit 8477d35

File tree

107 files changed

+952
-261
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+952
-261
lines changed

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ declare_lint! {
255255
pub CONST_ERR,
256256
Deny,
257257
"constant evaluation encountered erroneous expression",
258+
@future_incompatible = FutureIncompatibleInfo {
259+
reference: "issue #71800 <https://github.com/rust-lang/rust/issues/71800>",
260+
edition: None,
261+
};
258262
report_in_external_macro
259263
}
260264

src/test/ui/array-slice-vec/array_const_index-0.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const A: &'static [i32] = &[];
22
const B: i32 = (&A)[1];
33
//~^ index out of bounds: the length is 0 but the index is 1
44
//~| ERROR any use of this value will cause an error
5+
//~| WARN this was previously accepted by the compiler but is being phased out
56

67
fn main() {
78
let _ = B;

src/test/ui/array-slice-vec/array_const_index-0.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ LL | const B: i32 = (&A)[1];
77
| index out of bounds: the length is 0 but the index is 1
88
|
99
= note: `#[deny(const_err)]` on by default
10+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
11+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
1012

1113
error: aborting due to previous error
1214

src/test/ui/array-slice-vec/array_const_index-1.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const A: [i32; 0] = [];
22
const B: i32 = A[1];
33
//~^ index out of bounds: the length is 0 but the index is 1
44
//~| ERROR any use of this value will cause an error
5+
//~| WARN this was previously accepted by the compiler but is being phased out
56

67
fn main() {
78
let _ = B;

src/test/ui/array-slice-vec/array_const_index-1.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ LL | const B: i32 = A[1];
77
| index out of bounds: the length is 0 but the index is 1
88
|
99
= note: `#[deny(const_err)]` on by default
10+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
11+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
1012

1113
error: aborting due to previous error
1214

src/test/ui/associated-consts/defaults-not-assumed-fail.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ trait Tr {
77
// `Self::A` must not be assumed to hold inside the trait.
88
const B: u8 = Self::A + 1;
99
//~^ ERROR any use of this value will cause an error
10+
//~| WARN this was previously accepted by the compiler but is being phased out
1011
}
1112

1213
// An impl that doesn't override any constant will NOT cause a const eval error
@@ -33,6 +34,7 @@ fn main() {
3334
assert_eq!(<() as Tr>::B, 0); // causes the error above
3435
//~^ ERROR evaluation of constant value failed
3536
//~| ERROR erroneous constant used
37+
//~| WARN this was previously accepted by the compiler but is being phased out
3638

3739
assert_eq!(<u8 as Tr>::A, 254);
3840
assert_eq!(<u8 as Tr>::B, 255);

src/test/ui/associated-consts/defaults-not-assumed-fail.stderr

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,23 @@ LL | const B: u8 = Self::A + 1;
77
| attempt to compute `u8::MAX + 1_u8`, which would overflow
88
|
99
= note: `#[deny(const_err)]` on by default
10+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
11+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
1012

1113
error[E0080]: evaluation of constant value failed
12-
--> $DIR/defaults-not-assumed-fail.rs:33:16
14+
--> $DIR/defaults-not-assumed-fail.rs:34:16
1315
|
1416
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
1517
| ^^^^^^^^^^^^^ referenced constant has errors
1618

1719
error: erroneous constant used
18-
--> $DIR/defaults-not-assumed-fail.rs:33:5
20+
--> $DIR/defaults-not-assumed-fail.rs:34:5
1921
|
2022
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
2123
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
2224
|
25+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
26+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
2327
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2428

2529
error: aborting due to 3 previous errors

src/test/ui/const-ptr/out_of_bounds_read.stderr

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
1515
| ------------------------------------------------------
1616
|
1717
= note: `#[deny(const_err)]` on by default
18+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
19+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
1820

1921
error: any use of this value will cause an error
2022
--> $SRC_DIR/core/src/intrinsics.rs:LL:COL
@@ -32,6 +34,9 @@ LL | unsafe { copy_nonoverlapping(src, dst, count) }
3234
|
3335
LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
3436
| --------------------------------------------------------
37+
|
38+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
39+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
3540

3641
error: any use of this value will cause an error
3742
--> $SRC_DIR/core/src/intrinsics.rs:LL:COL
@@ -49,6 +54,9 @@ LL | unsafe { copy_nonoverlapping(src, dst, count) }
4954
|
5055
LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() };
5156
| --------------------------------------------------------------------
57+
|
58+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
59+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
5260

5361
error: aborting due to 3 previous errors
5462

src/test/ui/consts/assoc_const_generic_impl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ trait ZeroSized: Sized {
99

1010
impl<T: Sized> ZeroSized for T {
1111
const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()]; //~ WARN any use of this value
12+
//~| WARN this was previously accepted by the compiler but is being phased out
1213
fn requires_zero_size(self) {
1314
let () = Self::I_AM_ZERO_SIZED; //~ ERROR erroneous constant encountered
1415
println!("requires_zero_size called");

src/test/ui/consts/assoc_const_generic_impl.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ note: the lint level is defined here
1111
|
1212
LL | #![warn(const_err)]
1313
| ^^^^^^^^^
14+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
15+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
1416

1517
error: erroneous constant encountered
16-
--> $DIR/assoc_const_generic_impl.rs:13:18
18+
--> $DIR/assoc_const_generic_impl.rs:14:18
1719
|
1820
LL | let () = Self::I_AM_ZERO_SIZED;
1921
| ^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)