Skip to content

Commit

Permalink
make const_err show up in future breakage reports
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jun 25, 2022
1 parent 1aabd8a commit dc2cc10
Show file tree
Hide file tree
Showing 48 changed files with 2,008 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ declare_lint! {
"constant evaluation encountered erroneous expression",
@future_incompatible = FutureIncompatibleInfo {
reference: "issue #71800 <https://github.com/rust-lang/rust/issues/71800>",
reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
};
report_in_external_macro
}
Expand Down
13 changes: 13 additions & 0 deletions src/test/ui/array-slice-vec/array_const_index-0.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,16 @@ LL | const B: i32 = (&A)[1];

error: aborting due to previous error

Future incompatibility report: Future breakage diagnostic:
error: any use of this value will cause an error
--> $DIR/array_const_index-0.rs:2:16
|
LL | const B: i32 = (&A)[1];
| ---------------^^^^^^^-
| |
| index out of bounds: the length is 0 but the index is 1
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

13 changes: 13 additions & 0 deletions src/test/ui/array-slice-vec/array_const_index-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,16 @@ LL | const B: i32 = A[1];

error: aborting due to previous error

Future incompatibility report: Future breakage diagnostic:
error: any use of this value will cause an error
--> $DIR/array_const_index-1.rs:2:16
|
LL | const B: i32 = A[1];
| ---------------^^^^-
| |
| index out of bounds: the length is 0 but the index is 1
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

25 changes: 25 additions & 0 deletions src/test/ui/associated-consts/defaults-not-assumed-fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,28 @@ LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0080`.
Future incompatibility report: Future breakage diagnostic:
error: any use of this value will cause an error
--> $DIR/defaults-not-assumed-fail.rs:8:19
|
LL | const B: u8 = Self::A + 1;
| --------------^^^^^^^^^^^-
| |
| attempt to compute `u8::MAX + 1_u8`, which would overflow
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

Future breakage diagnostic:
error: erroneous constant used
--> $DIR/defaults-not-assumed-fail.rs:34:5
|
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

42 changes: 42 additions & 0 deletions src/test/ui/consts/assert-type-intrinsics.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,45 @@ LL | | };

error: aborting due to 3 previous errors

Future incompatibility report: Future breakage diagnostic:
error: any use of this value will cause an error
--> $DIR/assert-type-intrinsics.rs:14:9
|
LL | / const _BAD1: () = unsafe {
LL | | MaybeUninit::<!>::uninit().assume_init();
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to instantiate uninhabited type `!`
LL | | };
| |______-
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

Future breakage diagnostic:
error: any use of this value will cause an error
--> $DIR/assert-type-intrinsics.rs:17:9
|
LL | / const _BAD2: () = unsafe {
LL | | intrinsics::assert_uninit_valid::<bool>();
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to leave type `bool` uninitialized, which is invalid
LL | | };
| |______-
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

Future breakage diagnostic:
error: any use of this value will cause an error
--> $DIR/assert-type-intrinsics.rs:20:9
|
LL | / const _BAD3: () = unsafe {
LL | | intrinsics::assert_zero_valid::<&'static i32>();
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to zero-initialize type `&i32`, which is invalid
LL | | };
| |______-
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

17 changes: 17 additions & 0 deletions src/test/ui/consts/assoc_const_generic_impl.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,20 @@ LL | let () = Self::I_AM_ZERO_SIZED;

error: aborting due to previous error; 1 warning emitted

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

85 changes: 85 additions & 0 deletions src/test/ui/consts/const-err-early.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,88 @@ LL | pub const E: u8 = [5u8][1];

error: aborting due to 5 previous errors

Future incompatibility report: Future breakage diagnostic:
error: any use of this value will cause an error
--> $DIR/const-err-early.rs:3:19
|
LL | pub const A: i8 = -i8::MIN;
| ------------------^^^^^^^^-
| |
| attempt to negate `i8::MIN`, which would overflow
|
note: the lint level is defined here
--> $DIR/const-err-early.rs:1:9
|
LL | #![deny(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

Future breakage diagnostic:
error: any use of this value will cause an error
--> $DIR/const-err-early.rs:5:19
|
LL | pub const B: u8 = 200u8 + 200u8;
| ------------------^^^^^^^^^^^^^-
| |
| attempt to compute `200_u8 + 200_u8`, which would overflow
|
note: the lint level is defined here
--> $DIR/const-err-early.rs:1:9
|
LL | #![deny(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

Future breakage diagnostic:
error: any use of this value will cause an error
--> $DIR/const-err-early.rs:7:19
|
LL | pub const C: u8 = 200u8 * 4;
| ------------------^^^^^^^^^-
| |
| attempt to compute `200_u8 * 4_u8`, which would overflow
|
note: the lint level is defined here
--> $DIR/const-err-early.rs:1:9
|
LL | #![deny(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

Future breakage diagnostic:
error: any use of this value will cause an error
--> $DIR/const-err-early.rs:9:19
|
LL | pub const D: u8 = 42u8 - (42u8 + 1);
| ------------------^^^^^^^^^^^^^^^^^-
| |
| attempt to compute `42_u8 - 43_u8`, which would overflow
|
note: the lint level is defined here
--> $DIR/const-err-early.rs:1:9
|
LL | #![deny(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

Future breakage diagnostic:
error: any use of this value will cause an error
--> $DIR/const-err-early.rs:11:19
|
LL | pub const E: u8 = [5u8][1];
| ------------------^^^^^^^^-
| |
| index out of bounds: the length is 1 but the index is 1
|
note: the lint level is defined here
--> $DIR/const-err-early.rs:1:9
|
LL | #![deny(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

68 changes: 68 additions & 0 deletions src/test/ui/consts/const-err-multi.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,71 @@ LL | pub const D: i8 = 50 - A;

error: aborting due to 4 previous errors

Future incompatibility report: Future breakage diagnostic:
error: any use of this value will cause an error
--> $DIR/const-err-multi.rs:3:19
|
LL | pub const A: i8 = -i8::MIN;
| ------------------^^^^^^^^-
| |
| attempt to negate `i8::MIN`, which would overflow
|
note: the lint level is defined here
--> $DIR/const-err-multi.rs:1:9
|
LL | #![deny(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

Future breakage diagnostic:
error: any use of this value will cause an error
--> $DIR/const-err-multi.rs:6:19
|
LL | pub const B: i8 = A;
| ------------------^-
| |
| referenced constant has errors
|
note: the lint level is defined here
--> $DIR/const-err-multi.rs:1:9
|
LL | #![deny(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

Future breakage diagnostic:
error: any use of this value will cause an error
--> $DIR/const-err-multi.rs:9:19
|
LL | pub const C: u8 = A as u8;
| ------------------^-------
| |
| referenced constant has errors
|
note: the lint level is defined here
--> $DIR/const-err-multi.rs:1:9
|
LL | #![deny(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

Future breakage diagnostic:
error: any use of this value will cause an error
--> $DIR/const-err-multi.rs:12:24
|
LL | pub const D: i8 = 50 - A;
| -----------------------^-
| |
| referenced constant has errors
|
note: the lint level is defined here
--> $DIR/const-err-multi.rs:1:9
|
LL | #![deny(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

17 changes: 17 additions & 0 deletions src/test/ui/consts/const-err.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,20 @@ LL | black_box((FOO, FOO));
error: aborting due to 2 previous errors; 1 warning emitted

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

33 changes: 33 additions & 0 deletions src/test/ui/consts/const-eval/conditional_array_execution.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,36 @@ LL | println!("{}", FOO);
error: aborting due to previous error; 2 warnings emitted

For more information about this error, try `rustc --explain E0080`.
Future incompatibility report: Future breakage diagnostic:
warning: any use of this value will cause an error
--> $DIR/conditional_array_execution.rs:7:19
|
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
| ------------------^^^^^---------------------------
| |
| attempt to compute `5_u32 - 6_u32`, which would overflow
|
note: the lint level is defined here
--> $DIR/conditional_array_execution.rs:3:9
|
LL | #![warn(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

Future breakage diagnostic:
warning: erroneous constant used
--> $DIR/conditional_array_execution.rs:12:20
|
LL | println!("{}", FOO);
| ^^^ referenced constant has errors
|
note: the lint level is defined here
--> $DIR/conditional_array_execution.rs:3:9
|
LL | #![warn(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this warning originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)

17 changes: 17 additions & 0 deletions src/test/ui/consts/const-eval/const-eval-overflow-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,20 @@ LL | NEG_NEG_128 => println!("A"),

error: aborting due to 2 previous errors

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

Loading

0 comments on commit dc2cc10

Please sign in to comment.