Skip to content

Commit 7cf4f09

Browse files
Rollup merge of rust-lang#97743 - RalfJung:const-err-future-breakage, r=estebank
make const_err show up in future breakage reports As tracked in rust-lang#71800, const_err should become a hard error Any Day Now (TM). I'd love to move forward with that sooner rather than later; it has been deny-by-default for many years and a future incompat lint since rust-lang#80394 (landed more than a year ago). Some CTFE errors are already hard errors since rust-lang#86194. But before we truly make it a hard error in all cases, we now have one more intermediate step we can take -- to make it show up in future breakage reports. Cc `@rust-lang/wg-const-eval`
2 parents 459b151 + 4a4d877 commit 7cf4f09

File tree

54 files changed

+2112
-0
lines changed

Some content is hidden

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

54 files changed

+2112
-0
lines changed

compiler/rustc_lint_defs/src/builtin.rs

+1
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ declare_lint! {
289289
"constant evaluation encountered erroneous expression",
290290
@future_incompatible = FutureIncompatibleInfo {
291291
reference: "issue #71800 <https://github.com/rust-lang/rust/issues/71800>",
292+
reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
292293
};
293294
report_in_external_macro
294295
}

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

+13
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,16 @@ LL | const B: i32 = (&A)[1];
1212

1313
error: aborting due to previous error
1414

15+
Future incompatibility report: Future breakage diagnostic:
16+
error: any use of this value will cause an error
17+
--> $DIR/array_const_index-0.rs:2:16
18+
|
19+
LL | const B: i32 = (&A)[1];
20+
| ---------------^^^^^^^-
21+
| |
22+
| index out of bounds: the length is 0 but the index is 1
23+
|
24+
= note: `#[deny(const_err)]` on by default
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>
27+

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

+13
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,16 @@ LL | const B: i32 = A[1];
1212

1313
error: aborting due to previous error
1414

15+
Future incompatibility report: Future breakage diagnostic:
16+
error: any use of this value will cause an error
17+
--> $DIR/array_const_index-1.rs:2:16
18+
|
19+
LL | const B: i32 = A[1];
20+
| ---------------^^^^-
21+
| |
22+
| index out of bounds: the length is 0 but the index is 1
23+
|
24+
= note: `#[deny(const_err)]` on by default
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>
27+

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

+25
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,28 @@ LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
2929
error: aborting due to 3 previous errors
3030

3131
For more information about this error, try `rustc --explain E0080`.
32+
Future incompatibility report: Future breakage diagnostic:
33+
error: any use of this value will cause an error
34+
--> $DIR/defaults-not-assumed-fail.rs:8:19
35+
|
36+
LL | const B: u8 = Self::A + 1;
37+
| --------------^^^^^^^^^^^-
38+
| |
39+
| attempt to compute `u8::MAX + 1_u8`, which would overflow
40+
|
41+
= note: `#[deny(const_err)]` on by default
42+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
43+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
44+
45+
Future breakage diagnostic:
46+
error: erroneous constant used
47+
--> $DIR/defaults-not-assumed-fail.rs:34:5
48+
|
49+
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
50+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
51+
|
52+
= note: `#[deny(const_err)]` on by default
53+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
54+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
55+
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
56+

src/test/ui/consts/assert-type-intrinsics.stderr

+42
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,45 @@ LL | | };
3737

3838
error: aborting due to 3 previous errors
3939

40+
Future incompatibility report: Future breakage diagnostic:
41+
error: any use of this value will cause an error
42+
--> $DIR/assert-type-intrinsics.rs:14:9
43+
|
44+
LL | / const _BAD1: () = unsafe {
45+
LL | | MaybeUninit::<!>::uninit().assume_init();
46+
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to instantiate uninhabited type `!`
47+
LL | | };
48+
| |______-
49+
|
50+
= note: `#[deny(const_err)]` on by default
51+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
52+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
53+
54+
Future breakage diagnostic:
55+
error: any use of this value will cause an error
56+
--> $DIR/assert-type-intrinsics.rs:17:9
57+
|
58+
LL | / const _BAD2: () = unsafe {
59+
LL | | intrinsics::assert_uninit_valid::<bool>();
60+
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to leave type `bool` uninitialized, which is invalid
61+
LL | | };
62+
| |______-
63+
|
64+
= note: `#[deny(const_err)]` on by default
65+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
66+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
67+
68+
Future breakage diagnostic:
69+
error: any use of this value will cause an error
70+
--> $DIR/assert-type-intrinsics.rs:20:9
71+
|
72+
LL | / const _BAD3: () = unsafe {
73+
LL | | intrinsics::assert_zero_valid::<&'static i32>();
74+
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to zero-initialize type `&i32`, which is invalid
75+
LL | | };
76+
| |______-
77+
|
78+
= note: `#[deny(const_err)]` on by default
79+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
80+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
81+

src/test/ui/consts/assoc_const_generic_impl.stderr

+17
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,20 @@ LL | let () = Self::I_AM_ZERO_SIZED;
2222

2323
error: aborting due to previous error; 1 warning emitted
2424

25+
Future incompatibility report: Future breakage diagnostic:
26+
warning: any use of this value will cause an error
27+
--> $DIR/assoc_const_generic_impl.rs:11:34
28+
|
29+
LL | const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()];
30+
| -----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
31+
| |
32+
| index out of bounds: the length is 1 but the index is 4
33+
|
34+
note: the lint level is defined here
35+
--> $DIR/assoc_const_generic_impl.rs:3:9
36+
|
37+
LL | #![warn(const_err)]
38+
| ^^^^^^^^^
39+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
40+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
41+

src/test/ui/consts/const-err-early.stderr

+85
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,88 @@ LL | pub const E: u8 = [5u8][1];
6060

6161
error: aborting due to 5 previous errors
6262

63+
Future incompatibility report: Future breakage diagnostic:
64+
error: any use of this value will cause an error
65+
--> $DIR/const-err-early.rs:3:19
66+
|
67+
LL | pub const A: i8 = -i8::MIN;
68+
| ------------------^^^^^^^^-
69+
| |
70+
| attempt to negate `i8::MIN`, which would overflow
71+
|
72+
note: the lint level is defined here
73+
--> $DIR/const-err-early.rs:1:9
74+
|
75+
LL | #![deny(const_err)]
76+
| ^^^^^^^^^
77+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
78+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
79+
80+
Future breakage diagnostic:
81+
error: any use of this value will cause an error
82+
--> $DIR/const-err-early.rs:5:19
83+
|
84+
LL | pub const B: u8 = 200u8 + 200u8;
85+
| ------------------^^^^^^^^^^^^^-
86+
| |
87+
| attempt to compute `200_u8 + 200_u8`, which would overflow
88+
|
89+
note: the lint level is defined here
90+
--> $DIR/const-err-early.rs:1:9
91+
|
92+
LL | #![deny(const_err)]
93+
| ^^^^^^^^^
94+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
95+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
96+
97+
Future breakage diagnostic:
98+
error: any use of this value will cause an error
99+
--> $DIR/const-err-early.rs:7:19
100+
|
101+
LL | pub const C: u8 = 200u8 * 4;
102+
| ------------------^^^^^^^^^-
103+
| |
104+
| attempt to compute `200_u8 * 4_u8`, which would overflow
105+
|
106+
note: the lint level is defined here
107+
--> $DIR/const-err-early.rs:1:9
108+
|
109+
LL | #![deny(const_err)]
110+
| ^^^^^^^^^
111+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
112+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
113+
114+
Future breakage diagnostic:
115+
error: any use of this value will cause an error
116+
--> $DIR/const-err-early.rs:9:19
117+
|
118+
LL | pub const D: u8 = 42u8 - (42u8 + 1);
119+
| ------------------^^^^^^^^^^^^^^^^^-
120+
| |
121+
| attempt to compute `42_u8 - 43_u8`, which would overflow
122+
|
123+
note: the lint level is defined here
124+
--> $DIR/const-err-early.rs:1:9
125+
|
126+
LL | #![deny(const_err)]
127+
| ^^^^^^^^^
128+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
129+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
130+
131+
Future breakage diagnostic:
132+
error: any use of this value will cause an error
133+
--> $DIR/const-err-early.rs:11:19
134+
|
135+
LL | pub const E: u8 = [5u8][1];
136+
| ------------------^^^^^^^^-
137+
| |
138+
| index out of bounds: the length is 1 but the index is 1
139+
|
140+
note: the lint level is defined here
141+
--> $DIR/const-err-early.rs:1:9
142+
|
143+
LL | #![deny(const_err)]
144+
| ^^^^^^^^^
145+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
146+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
147+

src/test/ui/consts/const-err-multi.stderr

+68
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,71 @@ LL | pub const D: i8 = 50 - A;
4949

5050
error: aborting due to 4 previous errors
5151

52+
Future incompatibility report: Future breakage diagnostic:
53+
error: any use of this value will cause an error
54+
--> $DIR/const-err-multi.rs:3:19
55+
|
56+
LL | pub const A: i8 = -i8::MIN;
57+
| ------------------^^^^^^^^-
58+
| |
59+
| attempt to negate `i8::MIN`, which would overflow
60+
|
61+
note: the lint level is defined here
62+
--> $DIR/const-err-multi.rs:1:9
63+
|
64+
LL | #![deny(const_err)]
65+
| ^^^^^^^^^
66+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
67+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
68+
69+
Future breakage diagnostic:
70+
error: any use of this value will cause an error
71+
--> $DIR/const-err-multi.rs:6:19
72+
|
73+
LL | pub const B: i8 = A;
74+
| ------------------^-
75+
| |
76+
| referenced constant has errors
77+
|
78+
note: the lint level is defined here
79+
--> $DIR/const-err-multi.rs:1:9
80+
|
81+
LL | #![deny(const_err)]
82+
| ^^^^^^^^^
83+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
84+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
85+
86+
Future breakage diagnostic:
87+
error: any use of this value will cause an error
88+
--> $DIR/const-err-multi.rs:9:19
89+
|
90+
LL | pub const C: u8 = A as u8;
91+
| ------------------^-------
92+
| |
93+
| referenced constant has errors
94+
|
95+
note: the lint level is defined here
96+
--> $DIR/const-err-multi.rs:1:9
97+
|
98+
LL | #![deny(const_err)]
99+
| ^^^^^^^^^
100+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
101+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
102+
103+
Future breakage diagnostic:
104+
error: any use of this value will cause an error
105+
--> $DIR/const-err-multi.rs:12:24
106+
|
107+
LL | pub const D: i8 = 50 - A;
108+
| -----------------------^-
109+
| |
110+
| referenced constant has errors
111+
|
112+
note: the lint level is defined here
113+
--> $DIR/const-err-multi.rs:1:9
114+
|
115+
LL | #![deny(const_err)]
116+
| ^^^^^^^^^
117+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
118+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
119+

src/test/ui/consts/const-err.stderr

+17
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,20 @@ LL | black_box((FOO, FOO));
2929
error: aborting due to 2 previous errors; 1 warning emitted
3030

3131
For more information about this error, try `rustc --explain E0080`.
32+
Future incompatibility report: Future breakage diagnostic:
33+
warning: any use of this value will cause an error
34+
--> $DIR/const-err.rs:11:17
35+
|
36+
LL | const FOO: u8 = [5u8][1];
37+
| ----------------^^^^^^^^-
38+
| |
39+
| index out of bounds: the length is 1 but the index is 1
40+
|
41+
note: the lint level is defined here
42+
--> $DIR/const-err.rs:5:9
43+
|
44+
LL | #![warn(const_err)]
45+
| ^^^^^^^^^
46+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
47+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
48+

src/test/ui/consts/const-eval/conditional_array_execution.stderr

+33
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,36 @@ LL | println!("{}", FOO);
3333
error: aborting due to previous error; 2 warnings emitted
3434

3535
For more information about this error, try `rustc --explain E0080`.
36+
Future incompatibility report: Future breakage diagnostic:
37+
warning: any use of this value will cause an error
38+
--> $DIR/conditional_array_execution.rs:7:19
39+
|
40+
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
41+
| ------------------^^^^^---------------------------
42+
| |
43+
| attempt to compute `5_u32 - 6_u32`, which would overflow
44+
|
45+
note: the lint level is defined here
46+
--> $DIR/conditional_array_execution.rs:3:9
47+
|
48+
LL | #![warn(const_err)]
49+
| ^^^^^^^^^
50+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
51+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
52+
53+
Future breakage diagnostic:
54+
warning: erroneous constant used
55+
--> $DIR/conditional_array_execution.rs:12:20
56+
|
57+
LL | println!("{}", FOO);
58+
| ^^^ referenced constant has errors
59+
|
60+
note: the lint level is defined here
61+
--> $DIR/conditional_array_execution.rs:3:9
62+
|
63+
LL | #![warn(const_err)]
64+
| ^^^^^^^^^
65+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
66+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
67+
= note: this warning originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
68+

src/test/ui/consts/const-eval/const-eval-overflow-2.stderr

+17
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,20 @@ LL | NEG_NEG_128 => println!("A"),
1212

1313
error: aborting due to 2 previous errors
1414

15+
Future incompatibility report: Future breakage diagnostic:
16+
warning: any use of this value will cause an error
17+
--> $DIR/const-eval-overflow-2.rs:11:25
18+
|
19+
LL | const NEG_NEG_128: i8 = -NEG_128;
20+
| ------------------------^^^^^^^^-
21+
| |
22+
| attempt to negate `i8::MIN`, which would overflow
23+
|
24+
note: the lint level is defined here
25+
--> $DIR/const-eval-overflow-2.rs:4:36
26+
|
27+
LL | #![allow(unused_imports, warnings, const_err)]
28+
| ^^^^^^^^^
29+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
30+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
31+

0 commit comments

Comments
 (0)