From 94a0819fe3a0d679c3042a77bfe6a2afc505daea Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:11:28 +0200 Subject: Adding upstream version 1.66.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/consts/array-literal-index-oob.rs | 2 +- src/test/ui/consts/array-literal-index-oob.stderr | 6 +- src/test/ui/consts/assert-type-intrinsics.rs | 11 +- src/test/ui/consts/assert-type-intrinsics.stderr | 70 +-- src/test/ui/consts/assoc_const_generic_impl.rs | 7 +- src/test/ui/consts/assoc_const_generic_impl.stderr | 40 +- src/test/ui/consts/cast-discriminant-zst-enum.rs | 1 - src/test/ui/consts/const-block-const-bound.stderr | 4 +- .../const-blocks/fn-call-in-non-const.stderr | 2 +- .../ui/consts/const-blocks/migrate-fail.stderr | 4 +- src/test/ui/consts/const-blocks/nll-fail.stderr | 4 +- src/test/ui/consts/const-blocks/trait-error.stderr | 2 +- src/test/ui/consts/const-err-early.rs | 17 +- src/test/ui/consts/const-err-early.stderr | 126 +---- src/test/ui/consts/const-err-late.rs | 22 + src/test/ui/consts/const-err-late.stderr | 27 + src/test/ui/consts/const-err-multi.rs | 14 +- src/test/ui/consts/const-err-multi.stderr | 102 +--- src/test/ui/consts/const-err-rpass.rs | 2 - src/test/ui/consts/const-err.rs | 19 - src/test/ui/consts/const-err.stderr | 44 -- src/test/ui/consts/const-err4.32bit.stderr | 11 +- src/test/ui/consts/const-err4.64bit.stderr | 11 +- src/test/ui/consts/const-err4.rs | 3 +- .../const-eval/conditional_array_execution.rs | 10 +- .../const-eval/conditional_array_execution.stderr | 63 +-- .../ui/consts/const-eval/const-eval-overflow-2.rs | 4 +- .../consts/const-eval/const-eval-overflow-2.stderr | 24 +- .../const-eval/const-eval-overflow-3b.stderr | 4 +- .../const-eval/const-eval-overflow-4b.stderr | 4 +- .../ui/consts/const-eval/const-eval-overflow2.rs | 26 +- .../consts/const-eval/const-eval-overflow2.stderr | 226 +------- .../ui/consts/const-eval/const-eval-overflow2b.rs | 26 +- .../consts/const-eval/const-eval-overflow2b.stderr | 226 +------- .../ui/consts/const-eval/const-eval-overflow2c.rs | 26 +- .../consts/const-eval/const-eval-overflow2c.stderr | 226 +------- .../ui/consts/const-eval/const-eval-query-stack.rs | 10 +- .../const-eval/const-eval-query-stack.stderr | 64 +-- ...st-pointer-values-in-various-types.64bit.stderr | 588 +++------------------ .../const-pointer-values-in-various-types.rs | 87 ++- .../ui/consts/const-eval/const_fn_ptr_fail2.rs | 7 +- .../ui/consts/const-eval/const_fn_ptr_fail2.stderr | 92 +--- src/test/ui/consts/const-eval/const_let.rs | 8 +- src/test/ui/consts/const-eval/const_let.stderr | 16 +- .../const-eval/const_panic_stability.e2018.stderr | 2 +- .../ui/consts/const-eval/const_raw_ptr_ops.stderr | 20 - src/test/ui/consts/const-eval/erroneous-const.rs | 6 +- .../ui/consts/const-eval/erroneous-const.stderr | 45 +- src/test/ui/consts/const-eval/erroneous-const2.rs | 6 +- .../ui/consts/const-eval/erroneous-const2.stderr | 41 +- src/test/ui/consts/const-eval/format.rs | 4 - src/test/ui/consts/const-eval/format.stderr | 78 +-- .../heap/alloc_intrinsic_uninit.32bit.stderr | 2 +- .../heap/alloc_intrinsic_uninit.64bit.stderr | 2 +- .../const-eval/index-out-of-bounds-never-type.rs | 6 +- .../index-out-of-bounds-never-type.stderr | 38 +- src/test/ui/consts/const-eval/infinite_loop.rs | 2 +- src/test/ui/consts/const-eval/infinite_loop.stderr | 6 +- src/test/ui/consts/const-eval/issue-100878.rs | 8 + src/test/ui/consts/const-eval/issue-43197.rs | 16 +- src/test/ui/consts/const-eval/issue-43197.stderr | 119 +---- src/test/ui/consts/const-eval/issue-44578.rs | 5 +- src/test/ui/consts/const-eval/issue-44578.stderr | 43 +- src/test/ui/consts/const-eval/issue-50814-2.rs | 3 +- src/test/ui/consts/const-eval/issue-50814-2.stderr | 23 +- src/test/ui/consts/const-eval/issue-50814.rs | 3 +- src/test/ui/consts/const-eval/issue-50814.stderr | 23 +- src/test/ui/consts/const-eval/issue-65394.rs | 2 +- src/test/ui/consts/const-eval/issue-65394.stderr | 4 +- .../consts/const-eval/issue-91827-extern-types.rs | 1 - src/test/ui/consts/const-eval/livedrop.rs | 2 +- src/test/ui/consts/const-eval/livedrop.stderr | 4 +- .../ui/consts/const-eval/panic-assoc-never-type.rs | 1 - .../const-eval/panic-assoc-never-type.stderr | 6 +- src/test/ui/consts/const-eval/panic-never-type.rs | 1 - .../ui/consts/const-eval/panic-never-type.stderr | 4 +- .../ui/consts/const-eval/partial_ptr_overwrite.rs | 3 +- .../consts/const-eval/partial_ptr_overwrite.stderr | 25 +- .../ui/consts/const-eval/promoted_const_fn_fail.rs | 2 - .../const-eval/promoted_const_fn_fail.stderr | 2 +- .../promoted_const_fn_fail_deny_const_err.rs | 2 - .../promoted_const_fn_fail_deny_const_err.stderr | 2 +- .../consts/const-eval/promoted_errors.noopt.stderr | 93 +--- .../consts/const-eval/promoted_errors.opt.stderr | 95 +--- ...promoted_errors.opt_with_overflow_checks.stderr | 93 +--- src/test/ui/consts/const-eval/promoted_errors.rs | 25 +- src/test/ui/consts/const-eval/pub_const_err.rs | 10 - src/test/ui/consts/const-eval/pub_const_err.stderr | 31 -- src/test/ui/consts/const-eval/pub_const_err_bin.rs | 10 - .../ui/consts/const-eval/pub_const_err_bin.stderr | 31 -- .../const-eval/ref_to_int_match.32bit.stderr | 21 +- .../const-eval/ref_to_int_match.64bit.stderr | 21 +- src/test/ui/consts/const-eval/ref_to_int_match.rs | 3 +- src/test/ui/consts/const-eval/ub-enum-overwrite.rs | 3 +- .../ui/consts/const-eval/ub-enum-overwrite.stderr | 13 +- src/test/ui/consts/const-eval/ub-enum.32bit.stderr | 119 +---- src/test/ui/consts/const-eval/ub-enum.64bit.stderr | 119 +---- src/test/ui/consts/const-eval/ub-enum.rs | 21 +- .../ui/consts/const-eval/ub-int-array.32bit.stderr | 39 +- .../ui/consts/const-eval/ub-int-array.64bit.stderr | 39 +- src/test/ui/consts/const-eval/ub-int-array.rs | 13 +- .../ui/consts/const-eval/ub-nonnull.32bit.stderr | 17 +- .../ui/consts/const-eval/ub-nonnull.64bit.stderr | 17 +- src/test/ui/consts/const-eval/ub-nonnull.rs | 6 +- .../ui/consts/const-eval/ub-ref-ptr.32bit.stderr | 132 +---- .../ui/consts/const-eval/ub-ref-ptr.64bit.stderr | 132 +---- src/test/ui/consts/const-eval/ub-ref-ptr.rs | 21 +- .../ui/consts/const-eval/ub-uninhabit.32bit.stderr | 6 +- .../ui/consts/const-eval/ub-uninhabit.64bit.stderr | 6 +- src/test/ui/consts/const-eval/ub-uninhabit.rs | 1 - src/test/ui/consts/const-eval/ub-upvars.rs | 2 +- .../ui/consts/const-eval/ub-wide-ptr.32bit.stderr | 223 +++----- .../ui/consts/const-eval/ub-wide-ptr.64bit.stderr | 223 +++----- src/test/ui/consts/const-eval/ub-wide-ptr.rs | 36 +- .../ui/consts/const-eval/union-const-eval-field.rs | 3 +- .../const-eval/union-const-eval-field.stderr | 13 +- src/test/ui/consts/const-eval/union-ice.rs | 12 +- src/test/ui/consts/const-eval/union-ice.stderr | 39 +- .../ui/consts/const-eval/union-ub.32bit.stderr | 13 +- .../ui/consts/const-eval/union-ub.64bit.stderr | 13 +- src/test/ui/consts/const-eval/union-ub.rs | 4 +- src/test/ui/consts/const-eval/union_promotion.rs | 2 - .../ui/consts/const-eval/union_promotion.stderr | 2 +- .../ui/consts/const-eval/unused-broken-const.rs | 3 +- .../consts/const-eval/unused-broken-const.stderr | 20 +- src/test/ui/consts/const-eval/valid-const.rs | 1 - .../validate_uninhabited_zsts.32bit.stderr | 16 +- .../validate_uninhabited_zsts.64bit.stderr | 16 +- .../consts/const-eval/validate_uninhabited_zsts.rs | 2 - .../ui/consts/const-external-macro-const-err.rs | 3 +- .../consts/const-external-macro-const-err.stderr | 18 +- src/test/ui/consts/const-float-bits-reject-conv.rs | 24 +- .../ui/consts/const-float-bits-reject-conv.stderr | 239 +-------- src/test/ui/consts/const-fn-error.rs | 6 +- src/test/ui/consts/const-fn-error.stderr | 4 +- src/test/ui/consts/const-for.rs | 4 +- src/test/ui/consts/const-for.stderr | 4 +- .../ui/consts/const-int-arithmetic-overflow.rs | 1 - .../consts/const-len-underflow-separate-spans.rs | 3 +- .../const-len-underflow-separate-spans.stderr | 21 +- src/test/ui/consts/const-negation.rs | 2 - .../ui/consts/const-points-to-static.32bit.stderr | 2 +- .../ui/consts/const-points-to-static.64bit.stderr | 2 +- .../ui/consts/const-prop-read-static-in-const.rs | 3 +- .../consts/const-prop-read-static-in-const.stderr | 20 +- .../const-size_of_val-align_of_val-extern-type.rs | 6 +- ...nst-size_of_val-align_of_val-extern-type.stderr | 40 +- src/test/ui/consts/const-slice-oob.rs | 5 +- src/test/ui/consts/const-slice-oob.stderr | 22 +- src/test/ui/consts/const_discriminant.rs | 1 - .../const_in_pattern/custom-eq-branch-warn.stderr | 2 +- .../ui/consts/const_in_pattern/incomplete-slice.rs | 15 + .../const_in_pattern/incomplete-slice.stderr | 26 + .../ui/consts/const_in_pattern/issue-44333.stderr | 4 +- .../const_in_pattern/reject_non_structural.stderr | 4 +- .../const_in_pattern/warn_corner_cases.stderr | 2 +- .../consts/const_limit/const_eval_limit_reached.rs | 3 +- .../const_limit/const_eval_limit_reached.stderr | 24 +- .../ui/consts/const_unsafe_unreachable_ub.stderr | 10 +- .../consts/constifconst-call-in-const-position.rs | 22 + .../constifconst-call-in-const-position.stderr | 18 + .../consts/control-flow/drop-fail.precise.stderr | 8 +- src/test/ui/consts/control-flow/drop-fail.rs | 8 +- .../ui/consts/control-flow/drop-fail.stock.stderr | 16 +- src/test/ui/consts/control-flow/issue-50577.stderr | 2 +- src/test/ui/consts/dangling-alloc-id-ice.rs | 1 - src/test/ui/consts/dangling-alloc-id-ice.stderr | 2 +- src/test/ui/consts/drop_box.rs | 2 +- src/test/ui/consts/drop_box.stderr | 4 +- src/test/ui/consts/drop_zst.stderr | 4 +- .../ui/consts/extra-const-ub/detect-extra-ub.rs | 42 ++ .../detect-extra-ub.with_flag.stderr | 58 ++ src/test/ui/consts/extra-const-ub/issue-100771.rs | 20 + src/test/ui/consts/extra-const-ub/issue-101034.rs | 17 + src/test/ui/consts/invalid-union.32bit.stderr | 17 +- src/test/ui/consts/invalid-union.64bit.stderr | 17 +- src/test/ui/consts/invalid-union.rs | 1 - src/test/ui/consts/issue-102117.rs | 30 ++ src/test/ui/consts/issue-102117.stderr | 37 ++ src/test/ui/consts/issue-104155.rs | 5 + .../ui/consts/issue-17718-constants-not-static.rs | 9 + .../consts/issue-17718-constants-not-static.stderr | 12 + src/test/ui/consts/issue-25826.stderr | 4 - src/test/ui/consts/issue-32829-2.stderr | 2 + src/test/ui/consts/issue-36163.stderr | 2 +- src/test/ui/consts/issue-46553.rs | 1 - src/test/ui/consts/issue-56164.rs | 5 +- src/test/ui/consts/issue-56164.stderr | 22 +- src/test/ui/consts/issue-66693.rs | 3 +- src/test/ui/consts/issue-66693.stderr | 18 +- src/test/ui/consts/issue-78655.stderr | 5 + src/test/ui/consts/issue-88071.rs | 2 - src/test/ui/consts/issue-94675.rs | 5 +- src/test/ui/consts/issue-94675.stderr | 31 +- src/test/ui/consts/issue-miri-1910.rs | 1 + src/test/ui/consts/issue-miri-1910.stderr | 44 +- src/test/ui/consts/min_const_fn/min_const_fn.rs | 6 +- .../ui/consts/min_const_fn/min_const_fn.stderr | 20 +- src/test/ui/consts/mir_check_nonconst.stderr | 1 + src/test/ui/consts/miri_unleashed/abi-mismatch.rs | 1 - .../ui/consts/miri_unleashed/abi-mismatch.stderr | 8 +- src/test/ui/consts/miri_unleashed/assoc_const.rs | 2 - .../ui/consts/miri_unleashed/assoc_const.stderr | 46 +- src/test/ui/consts/miri_unleashed/assoc_const_2.rs | 4 +- .../ui/consts/miri_unleashed/assoc_const_2.stderr | 25 +- src/test/ui/consts/miri_unleashed/box.rs | 1 - src/test/ui/consts/miri_unleashed/box.stderr | 10 +- .../const_refers_to_static.32bit.stderr | 81 +++ .../const_refers_to_static.64bit.stderr | 81 +++ .../miri_unleashed/const_refers_to_static.rs | 34 +- .../miri_unleashed/const_refers_to_static.stderr | 100 ---- .../const_refers_to_static2.32bit.stderr | 38 -- .../const_refers_to_static2.64bit.stderr | 38 -- .../miri_unleashed/const_refers_to_static2.rs | 24 - ...const_refers_to_static_cross_crate.32bit.stderr | 108 +--- ...const_refers_to_static_cross_crate.64bit.stderr | 108 +--- .../const_refers_to_static_cross_crate.rs | 14 +- src/test/ui/consts/miri_unleashed/drop.rs | 1 - src/test/ui/consts/miri_unleashed/drop.stderr | 6 +- .../feature-gate-unleash_the_miri_inside_of_you.rs | 4 +- ...ture-gate-unleash_the_miri_inside_of_you.stderr | 6 +- src/test/ui/consts/miri_unleashed/inline_asm.rs | 1 - .../ui/consts/miri_unleashed/inline_asm.stderr | 4 +- .../ui/consts/miri_unleashed/mutable_references.rs | 1 - .../miri_unleashed/mutable_references.stderr | 12 +- .../mutable_references_err.32bit.stderr | 12 +- .../mutable_references_err.64bit.stderr | 12 +- .../miri_unleashed/mutable_references_err.rs | 2 - .../ui/consts/miri_unleashed/mutating_global.rs | 1 - .../consts/miri_unleashed/mutating_global.stderr | 2 +- src/test/ui/consts/miri_unleashed/non_const_fn.rs | 2 - .../ui/consts/miri_unleashed/non_const_fn.stderr | 4 +- src/test/ui/consts/miri_unleashed/ptr_arith.rs | 6 +- src/test/ui/consts/miri_unleashed/ptr_arith.stderr | 8 +- .../ui/consts/miri_unleashed/raw_mutable_const.rs | 2 - .../consts/miri_unleashed/raw_mutable_const.stderr | 4 +- src/test/ui/consts/miri_unleashed/slice_eq.rs | 12 +- src/test/ui/consts/miri_unleashed/tls.rs | 1 - src/test/ui/consts/miri_unleashed/tls.stderr | 8 +- src/test/ui/consts/offset.rs | 1 - src/test/ui/consts/offset_from.rs | 1 - src/test/ui/consts/offset_from_ub.rs | 2 +- src/test/ui/consts/promote-not.rs | 2 +- src/test/ui/consts/ptr_comparisons.rs | 30 +- src/test/ui/consts/ptr_comparisons.stderr | 49 +- .../ui/consts/qualif-indirect-mutation-fail.rs | 18 +- .../ui/consts/qualif-indirect-mutation-fail.stderr | 36 +- src/test/ui/consts/raw-ptr-const.rs | 2 - src/test/ui/consts/raw-ptr-const.stderr | 2 +- src/test/ui/consts/recursive.rs | 3 +- src/test/ui/consts/recursive.stderr | 31 +- .../consts/refs_check_const_eq-issue-88384.stderr | 2 +- .../consts/stable-precise-live-drops-in-libcore.rs | 2 +- .../stable-precise-live-drops-in-libcore.stderr | 4 +- src/test/ui/consts/trait_specialization.stderr | 2 +- .../ui/consts/uninhabited-const-issue-61744.rs | 3 +- .../ui/consts/uninhabited-const-issue-61744.stderr | 285 +++------- src/test/ui/consts/unnormalized-param-env.rs | 31 ++ src/test/ui/consts/unstable-const-fn-in-libcore.rs | 10 +- .../ui/consts/unstable-const-fn-in-libcore.stderr | 33 +- src/test/ui/consts/write_to_static_via_mut_ref.rs | 1 - .../ui/consts/write_to_static_via_mut_ref.stderr | 4 +- 262 files changed, 1843 insertions(+), 5219 deletions(-) create mode 100644 src/test/ui/consts/const-err-late.rs create mode 100644 src/test/ui/consts/const-err-late.stderr delete mode 100644 src/test/ui/consts/const-err.rs delete mode 100644 src/test/ui/consts/const-err.stderr create mode 100644 src/test/ui/consts/const-eval/issue-100878.rs delete mode 100644 src/test/ui/consts/const-eval/pub_const_err.rs delete mode 100644 src/test/ui/consts/const-eval/pub_const_err.stderr delete mode 100644 src/test/ui/consts/const-eval/pub_const_err_bin.rs delete mode 100644 src/test/ui/consts/const-eval/pub_const_err_bin.stderr create mode 100644 src/test/ui/consts/const_in_pattern/incomplete-slice.rs create mode 100644 src/test/ui/consts/const_in_pattern/incomplete-slice.stderr create mode 100644 src/test/ui/consts/constifconst-call-in-const-position.rs create mode 100644 src/test/ui/consts/constifconst-call-in-const-position.stderr create mode 100644 src/test/ui/consts/extra-const-ub/detect-extra-ub.rs create mode 100644 src/test/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr create mode 100644 src/test/ui/consts/extra-const-ub/issue-100771.rs create mode 100644 src/test/ui/consts/extra-const-ub/issue-101034.rs create mode 100644 src/test/ui/consts/issue-102117.rs create mode 100644 src/test/ui/consts/issue-102117.stderr create mode 100644 src/test/ui/consts/issue-104155.rs create mode 100644 src/test/ui/consts/issue-17718-constants-not-static.rs create mode 100644 src/test/ui/consts/issue-17718-constants-not-static.stderr create mode 100644 src/test/ui/consts/miri_unleashed/const_refers_to_static.32bit.stderr create mode 100644 src/test/ui/consts/miri_unleashed/const_refers_to_static.64bit.stderr delete mode 100644 src/test/ui/consts/miri_unleashed/const_refers_to_static.stderr delete mode 100644 src/test/ui/consts/miri_unleashed/const_refers_to_static2.32bit.stderr delete mode 100644 src/test/ui/consts/miri_unleashed/const_refers_to_static2.64bit.stderr delete mode 100644 src/test/ui/consts/miri_unleashed/const_refers_to_static2.rs create mode 100644 src/test/ui/consts/unnormalized-param-env.rs (limited to 'src/test/ui/consts') diff --git a/src/test/ui/consts/array-literal-index-oob.rs b/src/test/ui/consts/array-literal-index-oob.rs index 9b3f735b1..67b49b1ba 100644 --- a/src/test/ui/consts/array-literal-index-oob.rs +++ b/src/test/ui/consts/array-literal-index-oob.rs @@ -1,7 +1,7 @@ // build-pass // ignore-pass (test emits codegen-time warnings and verifies that they are not errors) -#![warn(const_err, unconditional_panic)] +#![warn(unconditional_panic)] fn main() { &{ [1, 2, 3][4] }; diff --git a/src/test/ui/consts/array-literal-index-oob.stderr b/src/test/ui/consts/array-literal-index-oob.stderr index f96b8d48b..54bf3af81 100644 --- a/src/test/ui/consts/array-literal-index-oob.stderr +++ b/src/test/ui/consts/array-literal-index-oob.stderr @@ -5,10 +5,10 @@ LL | &{ [1, 2, 3][4] }; | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 | note: the lint level is defined here - --> $DIR/array-literal-index-oob.rs:4:20 + --> $DIR/array-literal-index-oob.rs:4:9 | -LL | #![warn(const_err, unconditional_panic)] - | ^^^^^^^^^^^^^^^^^^^ +LL | #![warn(unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ warning: 1 warning emitted diff --git a/src/test/ui/consts/assert-type-intrinsics.rs b/src/test/ui/consts/assert-type-intrinsics.rs index 38e5c454e..263d1ae6a 100644 --- a/src/test/ui/consts/assert-type-intrinsics.rs +++ b/src/test/ui/consts/assert-type-intrinsics.rs @@ -1,5 +1,3 @@ -// error-pattern: any use of this value will cause an error - #![feature(never_type)] #![feature(const_assert_type2)] #![feature(core_intrinsics)] @@ -12,11 +10,14 @@ fn main() { const _BAD1: () = unsafe { MaybeUninit::::uninit().assume_init(); + //~^ERROR: evaluation of constant value failed }; - const _BAD2: () = unsafe { - intrinsics::assert_uninit_valid::(); + const _BAD2: () = { + intrinsics::assert_uninit_valid::<&'static i32>(); + //~^ERROR: evaluation of constant value failed }; - const _BAD3: () = unsafe { + const _BAD3: () = { intrinsics::assert_zero_valid::<&'static i32>(); + //~^ERROR: evaluation of constant value failed }; } diff --git a/src/test/ui/consts/assert-type-intrinsics.stderr b/src/test/ui/consts/assert-type-intrinsics.stderr index f3b9170d4..f92f9fda0 100644 --- a/src/test/ui/consts/assert-type-intrinsics.stderr +++ b/src/test/ui/consts/assert-type-intrinsics.stderr @@ -1,75 +1,21 @@ -error: any use of this value will cause an error - --> $DIR/assert-type-intrinsics.rs:14:9 +error[E0080]: evaluation of constant value failed + --> $DIR/assert-type-intrinsics.rs:12:9 | -LL | const _BAD1: () = unsafe { - | --------------- LL | MaybeUninit::::uninit().assume_init(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to instantiate uninhabited type `!` - | - = 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 -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::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to leave type `bool` uninitialized, which is invalid +error[E0080]: evaluation of constant value failed + --> $DIR/assert-type-intrinsics.rs:16:9 | - = 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 +LL | intrinsics::assert_uninit_valid::<&'static i32>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to leave type `&i32` uninitialized, which is invalid -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $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 - | - = 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 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 `!` - | - = 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 - -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::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to leave type `bool` uninitialized, which is invalid - | - = 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 - -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 - | - = 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 - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/assoc_const_generic_impl.rs b/src/test/ui/consts/assoc_const_generic_impl.rs index 71d947b0c..3475c862b 100644 --- a/src/test/ui/consts/assoc_const_generic_impl.rs +++ b/src/test/ui/consts/assoc_const_generic_impl.rs @@ -1,17 +1,14 @@ // build-fail -#![warn(const_err)] - trait ZeroSized: Sized { const I_AM_ZERO_SIZED: (); fn requires_zero_size(self); } impl ZeroSized for T { - const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::()]; //~ WARN any use of this value - //~| WARN this was previously accepted by the compiler but is being phased out + const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::()]; //~ ERROR evaluation of `::I_AM_ZERO_SIZED` failed fn requires_zero_size(self) { - let () = Self::I_AM_ZERO_SIZED; //~ ERROR erroneous constant encountered + let () = Self::I_AM_ZERO_SIZED; println!("requires_zero_size called"); } } diff --git a/src/test/ui/consts/assoc_const_generic_impl.stderr b/src/test/ui/consts/assoc_const_generic_impl.stderr index 17cbaef1f..854b9ce5b 100644 --- a/src/test/ui/consts/assoc_const_generic_impl.stderr +++ b/src/test/ui/consts/assoc_const_generic_impl.stderr @@ -1,37 +1,15 @@ -warning: any use of this value will cause an error - --> $DIR/assoc_const_generic_impl.rs:11:34 +error[E0080]: evaluation of `::I_AM_ZERO_SIZED` failed + --> $DIR/assoc_const_generic_impl.rs:9:34 | LL | const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::()]; - | ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 4 -error: erroneous constant encountered - --> $DIR/assoc_const_generic_impl.rs:14:18 +note: the above error was encountered while instantiating `fn ::requires_zero_size` + --> $DIR/assoc_const_generic_impl.rs:18:5 | -LL | let () = Self::I_AM_ZERO_SIZED; - | ^^^^^^^^^^^^^^^^^^^^^ +LL | 42_u32.requires_zero_size(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -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::()]; - | ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 +error: aborting due to previous error +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/cast-discriminant-zst-enum.rs b/src/test/ui/consts/cast-discriminant-zst-enum.rs index e59ae297d..2767f178f 100644 --- a/src/test/ui/consts/cast-discriminant-zst-enum.rs +++ b/src/test/ui/consts/cast-discriminant-zst-enum.rs @@ -1,6 +1,5 @@ // run-pass // Test a ZST enum whose dicriminant is ~0i128. This caused an ICE when casting to an i32. -#![feature(bench_black_box)] use std::hint::black_box; #[derive(Copy, Clone)] diff --git a/src/test/ui/consts/const-block-const-bound.stderr b/src/test/ui/consts/const-block-const-bound.stderr index 87ca771e5..b9c4d8866 100644 --- a/src/test/ui/consts/const-block-const-bound.stderr +++ b/src/test/ui/consts/const-block-const-bound.stderr @@ -2,7 +2,7 @@ error[E0277]: can't drop `UnconstDrop` in const contexts --> $DIR/const-block-const-bound.rs:20:11 | LL | f(UnconstDrop); - | - ^^^^^^^^^^^ expected an implementor of trait `~const Destruct` + | - ^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `UnconstDrop` | | | required by a bound introduced by this call | @@ -23,7 +23,7 @@ error[E0277]: can't drop `NonDrop` in const contexts --> $DIR/const-block-const-bound.rs:22:11 | LL | f(NonDrop); - | - ^^^^^^^ expected an implementor of trait `~const Destruct` + | - ^^^^^^^ the trait `~const Destruct` is not implemented for `NonDrop` | | | required by a bound introduced by this call | diff --git a/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr b/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr index 5306fed22..ee352700c 100644 --- a/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr +++ b/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `Bar: Copy` is not satisfied LL | let _: [Option; 2] = [no_copy(); 2]; | ^^^^^^^^^ the trait `Copy` is not implemented for `Bar` | - = note: required because of the requirements on the impl of `Copy` for `Option` + = note: required for `Option` to implement `Copy` = note: the `Copy` trait is required because this value will be copied for each element of the array = help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position, like `const VAL: Type = const_fn();` and `let x = [VAL; 42];` = help: create an inline `const` block, see RFC #2920 for more information diff --git a/src/test/ui/consts/const-blocks/migrate-fail.stderr b/src/test/ui/consts/const-blocks/migrate-fail.stderr index 803281c07..928ffd083 100644 --- a/src/test/ui/consts/const-blocks/migrate-fail.stderr +++ b/src/test/ui/consts/const-blocks/migrate-fail.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `Bar: Copy` is not satisfied LL | let arr: [Option; 2] = [x; 2]; | ^ the trait `Copy` is not implemented for `Bar` | - = note: required because of the requirements on the impl of `Copy` for `Option` + = note: required for `Option` to implement `Copy` = note: the `Copy` trait is required because this value will be copied for each element of the array help: consider annotating `Bar` with `#[derive(Copy)]` | @@ -17,7 +17,7 @@ error[E0277]: the trait bound `Bar: Copy` is not satisfied LL | let arr: [Option; 2] = [x; 2]; | ^ the trait `Copy` is not implemented for `Bar` | - = note: required because of the requirements on the impl of `Copy` for `Option` + = note: required for `Option` to implement `Copy` = note: the `Copy` trait is required because this value will be copied for each element of the array help: consider annotating `Bar` with `#[derive(Copy)]` | diff --git a/src/test/ui/consts/const-blocks/nll-fail.stderr b/src/test/ui/consts/const-blocks/nll-fail.stderr index 8841af15d..fede00845 100644 --- a/src/test/ui/consts/const-blocks/nll-fail.stderr +++ b/src/test/ui/consts/const-blocks/nll-fail.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `Bar: Copy` is not satisfied LL | let arr: [Option; 2] = [x; 2]; | ^ the trait `Copy` is not implemented for `Bar` | - = note: required because of the requirements on the impl of `Copy` for `Option` + = note: required for `Option` to implement `Copy` = note: the `Copy` trait is required because this value will be copied for each element of the array help: consider annotating `Bar` with `#[derive(Copy)]` | @@ -17,7 +17,7 @@ error[E0277]: the trait bound `Bar: Copy` is not satisfied LL | let arr: [Option; 2] = [x; 2]; | ^ the trait `Copy` is not implemented for `Bar` | - = note: required because of the requirements on the impl of `Copy` for `Option` + = note: required for `Option` to implement `Copy` = note: the `Copy` trait is required because this value will be copied for each element of the array help: consider annotating `Bar` with `#[derive(Copy)]` | diff --git a/src/test/ui/consts/const-blocks/trait-error.stderr b/src/test/ui/consts/const-blocks/trait-error.stderr index ece200ad1..b11dd4b80 100644 --- a/src/test/ui/consts/const-blocks/trait-error.stderr +++ b/src/test/ui/consts/const-blocks/trait-error.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `String: Copy` is not satisfied LL | [Foo(String::new()); 4]; | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` | -note: required because of the requirements on the impl of `Copy` for `Foo` +note: required for `Foo` to implement `Copy` --> $DIR/trait-error.rs:1:10 | LL | #[derive(Copy, Clone)] diff --git a/src/test/ui/consts/const-err-early.rs b/src/test/ui/consts/const-err-early.rs index d8f7635fe..a3105b4fc 100644 --- a/src/test/ui/consts/const-err-early.rs +++ b/src/test/ui/consts/const-err-early.rs @@ -1,15 +1,8 @@ -#![deny(const_err)] - -pub const A: i8 = -i8::MIN; //~ ERROR const_err -//~| WARN this was previously accepted by the compiler but is being phased out -pub const B: u8 = 200u8 + 200u8; //~ ERROR const_err -//~| WARN this was previously accepted by the compiler but is being phased out -pub const C: u8 = 200u8 * 4; //~ ERROR const_err -//~| WARN this was previously accepted by the compiler but is being phased out -pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR const_err -//~| WARN this was previously accepted by the compiler but is being phased out -pub const E: u8 = [5u8][1]; //~ ERROR const_err -//~| WARN this was previously accepted by the compiler but is being phased out +pub const A: i8 = -i8::MIN; //~ ERROR constant +pub const B: u8 = 200u8 + 200u8; //~ ERROR constant +pub const C: u8 = 200u8 * 4; //~ ERROR constant +pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR constant +pub const E: u8 = [5u8][1]; //~ ERROR constant fn main() { let _a = A; diff --git a/src/test/ui/consts/const-err-early.stderr b/src/test/ui/consts/const-err-early.stderr index 1b94aa080..59bf637b7 100644 --- a/src/test/ui/consts/const-err-early.stderr +++ b/src/test/ui/consts/const-err-early.stderr @@ -1,127 +1,33 @@ -error: any use of this value will cause an error - --> $DIR/const-err-early.rs:3:19 +error[E0080]: evaluation of constant value failed + --> $DIR/const-err-early.rs:1: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 + | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow -error: any use of this value will cause an error - --> $DIR/const-err-early.rs:5:19 +error[E0080]: evaluation of constant value failed + --> $DIR/const-err-early.rs:2:19 | LL | pub const B: u8 = 200u8 + 200u8; - | --------------- ^^^^^^^^^^^^^ attempt to compute `200_u8 + 200_u8`, which would overflow - | - = 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 + | ^^^^^^^^^^^^^ attempt to compute `200_u8 + 200_u8`, which would overflow -error: any use of this value will cause an error - --> $DIR/const-err-early.rs:7:19 +error[E0080]: evaluation of constant value failed + --> $DIR/const-err-early.rs:3:19 | LL | pub const C: u8 = 200u8 * 4; - | --------------- ^^^^^^^^^ attempt to compute `200_u8 * 4_u8`, which would overflow - | - = 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 + | ^^^^^^^^^ attempt to compute `200_u8 * 4_u8`, which would overflow -error: any use of this value will cause an error - --> $DIR/const-err-early.rs:9:19 +error[E0080]: evaluation of constant value failed + --> $DIR/const-err-early.rs:4:19 | LL | pub const D: u8 = 42u8 - (42u8 + 1); - | --------------- ^^^^^^^^^^^^^^^^^ attempt to compute `42_u8 - 43_u8`, which would overflow - | - = 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 + | ^^^^^^^^^^^^^^^^^ attempt to compute `42_u8 - 43_u8`, which would overflow -error: any use of this value will cause an error - --> $DIR/const-err-early.rs:11:19 +error[E0080]: evaluation of constant value failed + --> $DIR/const-err-early.rs:5:19 | LL | pub const E: u8 = [5u8][1]; - | --------------- ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 - | - = 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 + | ^^^^^^^^ index out of bounds: the length is 1 but the index is 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 - -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 - -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 - -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 - -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 - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-err-late.rs b/src/test/ui/consts/const-err-late.rs new file mode 100644 index 000000000..a20ae7025 --- /dev/null +++ b/src/test/ui/consts/const-err-late.rs @@ -0,0 +1,22 @@ +// build-fail +// compile-flags: -C overflow-checks=on + +#![allow(arithmetic_overflow, unconditional_panic)] + +fn black_box(_: T) { + unimplemented!() +} + +struct S(T); + +impl S { + const FOO: u8 = [5u8][1]; + //~^ ERROR evaluation of `S::::FOO` failed + //~| ERROR evaluation of `S::::FOO` failed +} + +fn main() { + black_box((S::::FOO, S::::FOO)); + //~^ ERROR erroneous constant + //~| ERROR erroneous constant +} diff --git a/src/test/ui/consts/const-err-late.stderr b/src/test/ui/consts/const-err-late.stderr new file mode 100644 index 000000000..3a8b10317 --- /dev/null +++ b/src/test/ui/consts/const-err-late.stderr @@ -0,0 +1,27 @@ +error[E0080]: evaluation of `S::::FOO` failed + --> $DIR/const-err-late.rs:13:21 + | +LL | const FOO: u8 = [5u8][1]; + | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 + +error[E0080]: erroneous constant used + --> $DIR/const-err-late.rs:19:16 + | +LL | black_box((S::::FOO, S::::FOO)); + | ^^^^^^^^^^^^^ referenced constant has errors + +error[E0080]: evaluation of `S::::FOO` failed + --> $DIR/const-err-late.rs:13:21 + | +LL | const FOO: u8 = [5u8][1]; + | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 + +error[E0080]: erroneous constant used + --> $DIR/const-err-late.rs:19:31 + | +LL | black_box((S::::FOO, S::::FOO)); + | ^^^^^^^^^^^^^ referenced constant has errors + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-err-multi.rs b/src/test/ui/consts/const-err-multi.rs index 62552e147..fb26e8aac 100644 --- a/src/test/ui/consts/const-err-multi.rs +++ b/src/test/ui/consts/const-err-multi.rs @@ -1,17 +1,11 @@ -#![deny(const_err)] - pub const A: i8 = -i8::MIN; -//~^ ERROR const_err -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR constant pub const B: i8 = A; -//~^ ERROR const_err -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR constant pub const C: u8 = A as u8; -//~^ ERROR const_err -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR constant pub const D: i8 = 50 - A; -//~^ ERROR const_err -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR constant fn main() { let _ = (A, B, C, D); diff --git a/src/test/ui/consts/const-err-multi.stderr b/src/test/ui/consts/const-err-multi.stderr index f17984365..fca9e2270 100644 --- a/src/test/ui/consts/const-err-multi.stderr +++ b/src/test/ui/consts/const-err-multi.stderr @@ -1,103 +1,27 @@ -error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:3:19 +error[E0080]: evaluation of constant value failed + --> $DIR/const-err-multi.rs:1: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 + | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow -error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:6:19 +error[E0080]: evaluation of constant value failed + --> $DIR/const-err-multi.rs:3:19 | LL | pub const B: i8 = A; - | --------------- ^ referenced constant has errors - | - = 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 + | ^ referenced constant has errors -error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:9:19 +error[E0080]: evaluation of constant value failed + --> $DIR/const-err-multi.rs:5:19 | LL | pub const C: u8 = A as u8; - | --------------- ^ referenced constant has errors - | - = 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 + | ^ referenced constant has errors -error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:12:24 +error[E0080]: evaluation of constant value failed + --> $DIR/const-err-multi.rs:7:24 | LL | pub const D: i8 = 50 - A; - | --------------- ^ referenced constant has errors - | - = 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 + | ^ referenced constant has errors 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 - -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 - -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 - -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 - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-err-rpass.rs b/src/test/ui/consts/const-err-rpass.rs index 9851f1c58..e7fa10a2a 100644 --- a/src/test/ui/consts/const-err-rpass.rs +++ b/src/test/ui/consts/const-err-rpass.rs @@ -2,8 +2,6 @@ #![allow(dead_code)] // check for const_err regressions -#![deny(const_err)] - const X: *const u8 = b"" as _; const Y: bool = 'A' == 'B'; const Z: char = 'A'; diff --git a/src/test/ui/consts/const-err.rs b/src/test/ui/consts/const-err.rs deleted file mode 100644 index a8633fd87..000000000 --- a/src/test/ui/consts/const-err.rs +++ /dev/null @@ -1,19 +0,0 @@ -// build-fail -// compile-flags: -C overflow-checks=on - -#![allow(arithmetic_overflow)] -#![warn(const_err)] - -fn black_box(_: T) { - unimplemented!() -} - -const FOO: u8 = [5u8][1]; -//~^ WARN any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out - -fn main() { - black_box((FOO, FOO)); - //~^ ERROR erroneous constant used - //~| ERROR erroneous constant -} diff --git a/src/test/ui/consts/const-err.stderr b/src/test/ui/consts/const-err.stderr deleted file mode 100644 index e3b0d29c8..000000000 --- a/src/test/ui/consts/const-err.stderr +++ /dev/null @@ -1,44 +0,0 @@ -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 - -error[E0080]: erroneous constant used - --> $DIR/const-err.rs:16:16 - | -LL | black_box((FOO, FOO)); - | ^^^ referenced constant has errors - -error[E0080]: erroneous constant used - --> $DIR/const-err.rs:16:21 - | -LL | black_box((FOO, FOO)); - | ^^^ referenced constant has errors - -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 - diff --git a/src/test/ui/consts/const-err4.32bit.stderr b/src/test/ui/consts/const-err4.32bit.stderr index a55384783..1cbf78173 100644 --- a/src/test/ui/consts/const-err4.32bit.stderr +++ b/src/test/ui/consts/const-err4.32bit.stderr @@ -1,13 +1,8 @@ -error[E0080]: it is undefined behavior to use this value - --> $DIR/const-err4.rs:9:11 +error[E0080]: evaluation of constant value failed + --> $DIR/const-err4.rs:9:21 | LL | Boo = [unsafe { Foo { b: () }.a }; 4][3], - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered uninitialized bytes, but expected initialized bytes - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 4, align: 4) { - __ __ __ __ │ ░░░░ - } + | ^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error: aborting due to previous error diff --git a/src/test/ui/consts/const-err4.64bit.stderr b/src/test/ui/consts/const-err4.64bit.stderr index 66bfc30c3..1cbf78173 100644 --- a/src/test/ui/consts/const-err4.64bit.stderr +++ b/src/test/ui/consts/const-err4.64bit.stderr @@ -1,13 +1,8 @@ -error[E0080]: it is undefined behavior to use this value - --> $DIR/const-err4.rs:9:11 +error[E0080]: evaluation of constant value failed + --> $DIR/const-err4.rs:9:21 | LL | Boo = [unsafe { Foo { b: () }.a }; 4][3], - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered uninitialized bytes, but expected initialized bytes - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 8, align: 8) { - __ __ __ __ __ __ __ __ │ ░░░░░░░░ - } + | ^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error: aborting due to previous error diff --git a/src/test/ui/consts/const-err4.rs b/src/test/ui/consts/const-err4.rs index f0625faa8..107dc3f82 100644 --- a/src/test/ui/consts/const-err4.rs +++ b/src/test/ui/consts/const-err4.rs @@ -7,7 +7,8 @@ union Foo { enum Bar { Boo = [unsafe { Foo { b: () }.a }; 4][3], - //~^ ERROR it is undefined behavior to use this value + //~^ ERROR evaluation of constant value failed + //~| uninitialized } fn main() { diff --git a/src/test/ui/consts/const-eval/conditional_array_execution.rs b/src/test/ui/consts/const-eval/conditional_array_execution.rs index bd517e568..27d5383d6 100644 --- a/src/test/ui/consts/const-eval/conditional_array_execution.rs +++ b/src/test/ui/consts/const-eval/conditional_array_execution.rs @@ -1,16 +1,8 @@ -// build-fail - -#![warn(const_err)] - const X: u32 = 5; const Y: u32 = 6; const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; -//~^ WARN any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR constant fn main() { println!("{}", FOO); - //~^ ERROR evaluation of constant value failed - //~| WARN erroneous constant used [const_err] - //~| WARN this was previously accepted by the compiler but is being phased out } diff --git a/src/test/ui/consts/const-eval/conditional_array_execution.stderr b/src/test/ui/consts/const-eval/conditional_array_execution.stderr index 2953406ee..c3401fbae 100644 --- a/src/test/ui/consts/const-eval/conditional_array_execution.stderr +++ b/src/test/ui/consts/const-eval/conditional_array_execution.stderr @@ -1,64 +1,9 @@ -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 - error[E0080]: evaluation of constant value failed - --> $DIR/conditional_array_execution.rs:12:20 - | -LL | println!("{}", FOO); - | ^^^ referenced constant has errors - -warning: erroneous constant used - --> $DIR/conditional_array_execution.rs:12:20 - | -LL | println!("{}", FOO); - | ^^^ referenced constant has errors - | - = 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 - = note: this warning originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) - -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 + --> $DIR/conditional_array_execution.rs:3: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 + | ^^^^^ attempt to compute `5_u32 - 6_u32`, which would overflow -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 - = note: this warning originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +error: aborting due to previous error +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-2.rs b/src/test/ui/consts/const-eval/const-eval-overflow-2.rs index 9300d9576..535d91359 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-2.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow-2.rs @@ -1,14 +1,14 @@ // Evaluation of constants in refutable patterns goes through // different compiler control-flow paths. -#![allow(unused_imports, warnings, const_err)] +#![allow(unused_imports, warnings)] use std::fmt; use std::{i8, i16, i32, i64, isize}; use std::{u8, u16, u32, u64, usize}; const NEG_128: i8 = -128; -const NEG_NEG_128: i8 = -NEG_128; +const NEG_NEG_128: i8 = -NEG_128; //~ ERROR constant fn main() { match -128i8 { diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-2.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-2.stderr index cf50c19ca..7b1fe49d4 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-2.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-2.stderr @@ -1,3 +1,9 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow-2.rs:11:25 + | +LL | const NEG_NEG_128: i8 = -NEG_128; + | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + error: could not evaluate constant pattern --> $DIR/const-eval-overflow-2.rs:15:9 | @@ -10,20 +16,6 @@ error: could not evaluate constant pattern 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 +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr index 0e6be6d01..c685922c4 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr @@ -4,13 +4,13 @@ error[E0308]: mismatched types LL | = [0; (i8::MAX + 1u8) as usize]; | ^^^ expected `i8`, found `u8` -error[E0277]: cannot add `u8` to `i8` +error[E0277]: cannot add `u8` to `i8` in const contexts --> $DIR/const-eval-overflow-3b.rs:16:20 | LL | = [0; (i8::MAX + 1u8) as usize]; | ^ no implementation for `i8 + u8` | - = help: the trait `Add` is not implemented for `i8` + = help: the trait `~const Add` is not implemented for `i8` = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr index 4fa017e04..b39607924 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr @@ -4,13 +4,13 @@ error[E0308]: mismatched types LL | : [u32; (i8::MAX as i8 + 1u8) as usize] | ^^^ expected `i8`, found `u8` -error[E0277]: cannot add `u8` to `i8` +error[E0277]: cannot add `u8` to `i8` in const contexts --> $DIR/const-eval-overflow-4b.rs:9:28 | LL | : [u32; (i8::MAX as i8 + 1u8) as usize] | ^ no implementation for `i8 + u8` | - = help: the trait `Add` is not implemented for `i8` + = help: the trait `~const Add` is not implemented for `i8` = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2.rs b/src/test/ui/consts/const-eval/const-eval-overflow2.rs index b11f7d698..1676f7c2a 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2.rs @@ -5,63 +5,53 @@ // change this warn to a deny, then the compiler will exit before // those errors are detected. -#![deny(const_err)] - use std::fmt; const VALS_I8: (i8,) = ( i8::MIN - 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_I16: (i16,) = ( i16::MIN - 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_I32: (i32,) = ( i32::MIN - 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_I64: (i64,) = ( i64::MIN - 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U8: (u8,) = ( u8::MIN - 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U16: (u16,) = ( u16::MIN - 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U32: (u32,) = ( u32::MIN - 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U64: (u64,) = ( u64::MIN - 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed fn main() { foo(VALS_I8); diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2.stderr index dab9a76c7..341c15daf 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2.stderr @@ -1,243 +1,51 @@ -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:14:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2.rs:12:6 | -LL | const VALS_I8: (i8,) = - | -------------------- -LL | ( LL | i8::MIN - 1, | ^^^^^^^^^^^ attempt to compute `i8::MIN - 1_i8`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2.rs:8: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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:21:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2.rs:18:6 | -LL | const VALS_I16: (i16,) = - | ---------------------- -LL | ( LL | i16::MIN - 1, | ^^^^^^^^^^^^ attempt to compute `i16::MIN - 1_i16`, which would overflow - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:28:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2.rs:24:6 | -LL | const VALS_I32: (i32,) = - | ---------------------- -LL | ( LL | i32::MIN - 1, | ^^^^^^^^^^^^ attempt to compute `i32::MIN - 1_i32`, which would overflow - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:35:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2.rs:30:6 | -LL | const VALS_I64: (i64,) = - | ---------------------- -LL | ( LL | i64::MIN - 1, | ^^^^^^^^^^^^ attempt to compute `i64::MIN - 1_i64`, which would overflow - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:42:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2.rs:36:6 | -LL | const VALS_U8: (u8,) = - | -------------------- -LL | ( LL | u8::MIN - 1, | ^^^^^^^^^^^ attempt to compute `0_u8 - 1_u8`, which would overflow - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:48:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2.rs:41:6 | -LL | const VALS_U16: (u16,) = ( - | ---------------------- LL | u16::MIN - 1, | ^^^^^^^^^^^^ attempt to compute `0_u16 - 1_u16`, which would overflow - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:54:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2.rs:46:6 | -LL | const VALS_U32: (u32,) = ( - | ---------------------- LL | u32::MIN - 1, | ^^^^^^^^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:61:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2.rs:52:6 | -LL | const VALS_U64: (u64,) = - | ---------------------- -LL | ( LL | u64::MIN - 1, | ^^^^^^^^^^^^ attempt to compute `0_u64 - 1_u64`, which would overflow - | - = 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 error: aborting due to 8 previous errors -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:14:6 - | -LL | const VALS_I8: (i8,) = - | -------------------- -LL | ( -LL | i8::MIN - 1, - | ^^^^^^^^^^^ attempt to compute `i8::MIN - 1_i8`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:21:6 - | -LL | const VALS_I16: (i16,) = - | ---------------------- -LL | ( -LL | i16::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `i16::MIN - 1_i16`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:28:6 - | -LL | const VALS_I32: (i32,) = - | ---------------------- -LL | ( -LL | i32::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `i32::MIN - 1_i32`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:35:6 - | -LL | const VALS_I64: (i64,) = - | ---------------------- -LL | ( -LL | i64::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `i64::MIN - 1_i64`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:42:6 - | -LL | const VALS_U8: (u8,) = - | -------------------- -LL | ( -LL | u8::MIN - 1, - | ^^^^^^^^^^^ attempt to compute `0_u8 - 1_u8`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:48:6 - | -LL | const VALS_U16: (u16,) = ( - | ---------------------- -LL | u16::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `0_u16 - 1_u16`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:54:6 - | -LL | const VALS_U32: (u32,) = ( - | ---------------------- -LL | u32::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:61:6 - | -LL | const VALS_U64: (u64,) = - | ---------------------- -LL | ( -LL | u64::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `0_u64 - 1_u64`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2.rs:8: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 - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2b.rs b/src/test/ui/consts/const-eval/const-eval-overflow2b.rs index 9c3ad8ef9..59d1df568 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2b.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2b.rs @@ -5,63 +5,53 @@ // change this warn to a deny, then the compiler will exit before // those errors are detected. -#![deny(const_err)] - use std::fmt; const VALS_I8: (i8,) = ( i8::MAX + 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_I16: (i16,) = ( i16::MAX + 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_I32: (i32,) = ( i32::MAX + 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_I64: (i64,) = ( i64::MAX + 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U8: (u8,) = ( u8::MAX + 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U16: (u16,) = ( u16::MAX + 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U32: (u32,) = ( u32::MAX + 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U64: (u64,) = ( u64::MAX + 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed fn main() { foo(VALS_I8); diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr index 5fe991743..e661836b4 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr @@ -1,243 +1,51 @@ -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:14:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2b.rs:12:6 | -LL | const VALS_I8: (i8,) = - | -------------------- -LL | ( LL | i8::MAX + 1, | ^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2b.rs:8: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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:21:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2b.rs:18:6 | -LL | const VALS_I16: (i16,) = - | ---------------------- -LL | ( LL | i16::MAX + 1, | ^^^^^^^^^^^^ attempt to compute `i16::MAX + 1_i16`, which would overflow - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:28:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2b.rs:24:6 | -LL | const VALS_I32: (i32,) = - | ---------------------- -LL | ( LL | i32::MAX + 1, | ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:35:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2b.rs:30:6 | -LL | const VALS_I64: (i64,) = - | ---------------------- -LL | ( LL | i64::MAX + 1, | ^^^^^^^^^^^^ attempt to compute `i64::MAX + 1_i64`, which would overflow - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:42:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2b.rs:36:6 | -LL | const VALS_U8: (u8,) = - | -------------------- -LL | ( LL | u8::MAX + 1, | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:48:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2b.rs:41:6 | -LL | const VALS_U16: (u16,) = ( - | ---------------------- LL | u16::MAX + 1, | ^^^^^^^^^^^^ attempt to compute `u16::MAX + 1_u16`, which would overflow - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:54:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2b.rs:46:6 | -LL | const VALS_U32: (u32,) = ( - | ---------------------- LL | u32::MAX + 1, | ^^^^^^^^^^^^ attempt to compute `u32::MAX + 1_u32`, which would overflow - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:61:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2b.rs:52:6 | -LL | const VALS_U64: (u64,) = - | ---------------------- -LL | ( LL | u64::MAX + 1, | ^^^^^^^^^^^^ attempt to compute `u64::MAX + 1_u64`, which would overflow - | - = 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 error: aborting due to 8 previous errors -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:14:6 - | -LL | const VALS_I8: (i8,) = - | -------------------- -LL | ( -LL | i8::MAX + 1, - | ^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2b.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:21:6 - | -LL | const VALS_I16: (i16,) = - | ---------------------- -LL | ( -LL | i16::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `i16::MAX + 1_i16`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2b.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:28:6 - | -LL | const VALS_I32: (i32,) = - | ---------------------- -LL | ( -LL | i32::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2b.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:35:6 - | -LL | const VALS_I64: (i64,) = - | ---------------------- -LL | ( -LL | i64::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `i64::MAX + 1_i64`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2b.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:42:6 - | -LL | const VALS_U8: (u8,) = - | -------------------- -LL | ( -LL | u8::MAX + 1, - | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2b.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:48:6 - | -LL | const VALS_U16: (u16,) = ( - | ---------------------- -LL | u16::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `u16::MAX + 1_u16`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2b.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:54:6 - | -LL | const VALS_U32: (u32,) = ( - | ---------------------- -LL | u32::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `u32::MAX + 1_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2b.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:61:6 - | -LL | const VALS_U64: (u64,) = - | ---------------------- -LL | ( -LL | u64::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `u64::MAX + 1_u64`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2b.rs:8: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 - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2c.rs b/src/test/ui/consts/const-eval/const-eval-overflow2c.rs index bac4d042e..33b892601 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2c.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2c.rs @@ -5,63 +5,53 @@ // change this warn to a deny, then the compiler will exit before // those errors are detected. -#![deny(const_err)] - use std::fmt; const VALS_I8: (i8,) = ( i8::MIN * 2, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_I16: (i16,) = ( i16::MIN * 2, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_I32: (i32,) = ( i32::MIN * 2, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_I64: (i64,) = ( i64::MIN * 2, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U8: (u8,) = ( u8::MAX * 2, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U16: (u16,) = ( u16::MAX * 2, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U32: (u32,) = ( u32::MAX * 2, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U64: (u64,) = ( u64::MAX * 2, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed fn main() { foo(VALS_I8); diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr index d5f3a0fb1..1fad15492 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr @@ -1,243 +1,51 @@ -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:14:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2c.rs:12:6 | -LL | const VALS_I8: (i8,) = - | -------------------- -LL | ( LL | i8::MIN * 2, | ^^^^^^^^^^^ attempt to compute `i8::MIN * 2_i8`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2c.rs:8: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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:21:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2c.rs:18:6 | -LL | const VALS_I16: (i16,) = - | ---------------------- -LL | ( LL | i16::MIN * 2, | ^^^^^^^^^^^^ attempt to compute `i16::MIN * 2_i16`, which would overflow - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:28:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2c.rs:24:6 | -LL | const VALS_I32: (i32,) = - | ---------------------- -LL | ( LL | i32::MIN * 2, | ^^^^^^^^^^^^ attempt to compute `i32::MIN * 2_i32`, which would overflow - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:35:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2c.rs:30:6 | -LL | const VALS_I64: (i64,) = - | ---------------------- -LL | ( LL | i64::MIN * 2, | ^^^^^^^^^^^^ attempt to compute `i64::MIN * 2_i64`, which would overflow - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:42:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2c.rs:36:6 | -LL | const VALS_U8: (u8,) = - | -------------------- -LL | ( LL | u8::MAX * 2, | ^^^^^^^^^^^ attempt to compute `u8::MAX * 2_u8`, which would overflow - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:48:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2c.rs:41:6 | -LL | const VALS_U16: (u16,) = ( - | ---------------------- LL | u16::MAX * 2, | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 2_u16`, which would overflow - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:54:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2c.rs:46:6 | -LL | const VALS_U32: (u32,) = ( - | ---------------------- LL | u32::MAX * 2, | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 2_u32`, which would overflow - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:61:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2c.rs:52:6 | -LL | const VALS_U64: (u64,) = - | ---------------------- -LL | ( LL | u64::MAX * 2, | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 2_u64`, which would overflow - | - = 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 error: aborting due to 8 previous errors -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:14:6 - | -LL | const VALS_I8: (i8,) = - | -------------------- -LL | ( -LL | i8::MIN * 2, - | ^^^^^^^^^^^ attempt to compute `i8::MIN * 2_i8`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2c.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:21:6 - | -LL | const VALS_I16: (i16,) = - | ---------------------- -LL | ( -LL | i16::MIN * 2, - | ^^^^^^^^^^^^ attempt to compute `i16::MIN * 2_i16`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2c.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:28:6 - | -LL | const VALS_I32: (i32,) = - | ---------------------- -LL | ( -LL | i32::MIN * 2, - | ^^^^^^^^^^^^ attempt to compute `i32::MIN * 2_i32`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2c.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:35:6 - | -LL | const VALS_I64: (i64,) = - | ---------------------- -LL | ( -LL | i64::MIN * 2, - | ^^^^^^^^^^^^ attempt to compute `i64::MIN * 2_i64`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2c.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:42:6 - | -LL | const VALS_U8: (u8,) = - | -------------------- -LL | ( -LL | u8::MAX * 2, - | ^^^^^^^^^^^ attempt to compute `u8::MAX * 2_u8`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2c.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:48:6 - | -LL | const VALS_U16: (u16,) = ( - | ---------------------- -LL | u16::MAX * 2, - | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 2_u16`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2c.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:54:6 - | -LL | const VALS_U32: (u32,) = ( - | ---------------------- -LL | u32::MAX * 2, - | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 2_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2c.rs:8: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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:61:6 - | -LL | const VALS_U64: (u64,) = - | ---------------------- -LL | ( -LL | u64::MAX * 2, - | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 2_u64`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2c.rs:8: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 - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/const-eval-query-stack.rs b/src/test/ui/consts/const-eval/const-eval-query-stack.rs index c94604989..8f8a8cee3 100644 --- a/src/test/ui/consts/const-eval/const-eval-query-stack.rs +++ b/src/test/ui/consts/const-eval/const-eval-query-stack.rs @@ -1,5 +1,4 @@ -// compile-flags: -Ztreat-err-as-bug=2 -// build-fail +// compile-flags: -Ztreat-err-as-bug=1 // failure-status: 101 // rustc-env:RUST_BACKTRACE=1 // normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> "" @@ -15,14 +14,9 @@ #![allow(unconditional_panic)] -#[warn(const_err)] -const X: i32 = 1 / 0; //~WARN any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +const X: i32 = 1 / 0; //~ERROR constant fn main() { let x: &'static i32 = &X; - //~^ ERROR evaluation of constant value failed - //~| ERROR erroneous constant used - //~| WARNING this was previously accepted by the compiler println!("x={}", x); } diff --git a/src/test/ui/consts/const-eval/const-eval-query-stack.stderr b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr index 0ae7bfa86..b97975c4c 100644 --- a/src/test/ui/consts/const-eval/const-eval-query-stack.stderr +++ b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr @@ -1,61 +1,13 @@ -warning: any use of this value will cause an error - --> $DIR/const-eval-query-stack.rs:19:16 - | -LL | const X: i32 = 1 / 0; - | ------------ ^^^^^ attempt to divide `1_i32` by zero - | -note: the lint level is defined here - --> $DIR/const-eval-query-stack.rs:18:8 - | -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 - error[E0080]: evaluation of constant value failed - --> $DIR/const-eval-query-stack.rs:23:28 + --> $DIR/const-eval-query-stack.rs:17:16 | -LL | let x: &'static i32 = &X; - | ^ referenced constant has errors - -error: erroneous constant used - --> $DIR/const-eval-query-stack.rs:23:27 - | -LL | let x: &'static i32 = &X; - | ^^ 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 +LL | const X: i32 = 1 / 0; + | ^^^^^ attempt to divide `1_i32` by zero query stack during panic: -#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `main` -#1 [optimized_mir] optimizing MIR for `main` -#2 [collect_and_partition_mono_items] collect_and_partition_mono_items +#0 [eval_to_allocation_raw] const-evaluating + checking `X` +#1 [eval_to_const_value_raw] simplifying constant for the type system `X` +#2 [eval_to_const_value_raw] simplifying constant for the type system `X` +#3 [lint_mod] linting top-level module +#4 [analysis] running analysis passes on this crate end of query stack -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/const-eval-query-stack.rs:19:16 - | -LL | const X: i32 = 1 / 0; - | ------------ ^^^^^ attempt to divide `1_i32` by zero - | -note: the lint level is defined here - --> $DIR/const-eval-query-stack.rs:18:8 - | -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 - -Future breakage diagnostic: -error: erroneous constant used - --> $DIR/const-eval-query-stack.rs:23:27 - | -LL | let x: &'static i32 = &X; - | ^^ 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 - diff --git a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr index b7b00f7d7..bf98d0394 100644 --- a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr +++ b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr @@ -1,674 +1,258 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:26:49 | LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u }; - | -------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:30:43 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:29:43 | LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:34:45 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:32:45 | LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:38:45 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:35:45 | LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:42:45 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:38:45 | LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/const-pointer-values-in-various-types.rs:46:5 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:41:47 | LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered uninitialized bytes, but expected initialized bytes - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 16, align: 8) { - __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░ - } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:49:43 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:45:43 | LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:53:45 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:48:45 | LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:57:45 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:51:45 | LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:61:45 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:54:45 | LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/const-pointer-values-in-various-types.rs:65:5 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:57:47 | LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered uninitialized bytes, but expected initialized bytes - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 16, align: 8) { - __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░ - } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:68:45 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:61:45 | LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:72:45 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:64:45 | LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:76:47 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:67:47 | LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; - | ------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:80:47 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:70:47 | LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; - | ------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:84:39 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:73:39 | LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; - | ---------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:88:41 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:76:41 | LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:92:41 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:79:41 | LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:96:41 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:82:41 | LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:100:43 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:85:43 | LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:104:39 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:88:39 | LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; - | ---------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:108:41 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:91:41 | LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:112:41 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:94:41 | LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:116:41 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:97:41 | LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:120:43 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:100:43 | LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:124:41 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:103:41 | LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:128:41 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:106:41 | LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:132:43 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:109:43 | LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:136:43 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:112:43 | LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error: aborting due to 29 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/const-pointer-values-in-various-types.rs:26:49 - | -LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u }; - | -------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:30:43 - | -LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:34:45 - | -LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:38:45 - | -LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:42:45 - | -LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:49:43 - | -LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:53:45 - | -LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:57:45 - | -LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:61:45 - | -LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:68:45 - | -LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:72:45 - | -LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:76:47 - | -LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; - | ------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:80:47 - | -LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; - | ------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:84:39 - | -LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; - | ---------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:88:41 - | -LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:92:41 - | -LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:96:41 - | -LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:100:43 - | -LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:104:39 - | -LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; - | ---------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:108:41 - | -LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:112:41 - | -LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:116:41 - | -LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:120:43 - | -LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:124:41 - | -LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:128:41 - | -LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:132:43 - | -LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:136:43 - | -LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - diff --git a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs index f10a67392..45eed9d84 100644 --- a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs +++ b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs @@ -24,116 +24,91 @@ union Nonsense { fn main() { const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 }; - //~^ ERROR it is undefined behavior to use this value + //~^ ERROR evaluation of constant value failed + //~| uninitialized const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 }; - //~^ ERROR it is undefined behavior to use this value + //~^ ERROR evaluation of constant value failed + //~| uninitialized const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed } diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs index 804ebf660..b873940c4 100644 --- a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs +++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs @@ -1,8 +1,5 @@ -// build-fail // compile-flags: -Zunleash-the-miri-inside-of-you -#![allow(const_err)] - fn double(x: usize) -> usize { x * 2 } @@ -10,6 +7,8 @@ const X: fn(usize) -> usize = double; const fn bar(x: fn(usize) -> usize, y: usize) -> usize { x(y) + //~^ ERROR evaluation of constant value failed + //~| ERROR evaluation of constant value failed } const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday @@ -17,7 +16,5 @@ const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday fn main() { assert_eq!(Y, 4); - //~^ ERROR evaluation of constant value failed assert_eq!(Z, 4); - //~^ ERROR evaluation of constant value failed } diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr index f6ffa1ef2..3784a3861 100644 --- a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr +++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr @@ -1,99 +1,35 @@ error[E0080]: evaluation of constant value failed - --> $DIR/const_fn_ptr_fail2.rs:19:16 - | -LL | assert_eq!(Y, 4); - | ^ referenced constant has errors - -error[E0080]: evaluation of constant value failed - --> $DIR/const_fn_ptr_fail2.rs:21:16 - | -LL | assert_eq!(Z, 4); - | ^ referenced constant has errors - -warning: skipping const checks - | -help: skipping check that does not even have a feature gate - --> $DIR/const_fn_ptr_fail2.rs:12:5 - | -LL | x(y) - | ^^^^ - -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_fn_ptr_fail2.rs:12:5 + --> $DIR/const_fn_ptr_fail2.rs:9:5 | LL | x(y) | ^^^^ | | | calling non-const function `double` - | inside `bar` at $DIR/const_fn_ptr_fail2.rs:12:5 - | inside `Y` at $DIR/const_fn_ptr_fail2.rs:15:18 + | inside `bar` at $DIR/const_fn_ptr_fail2.rs:9:5 ... LL | const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday - | -------------- - | -note: the lint level is defined here - --> $DIR/const_fn_ptr_fail2.rs:4:10 - | -LL | #![allow(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 + | --------- inside `Y` at $DIR/const_fn_ptr_fail2.rs:14:18 -Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/const_fn_ptr_fail2.rs:12:5 +error[E0080]: evaluation of constant value failed + --> $DIR/const_fn_ptr_fail2.rs:9:5 | LL | x(y) | ^^^^ | | | calling non-const function `double` - | inside `bar` at $DIR/const_fn_ptr_fail2.rs:12:5 - | inside `Z` at $DIR/const_fn_ptr_fail2.rs:16:18 + | inside `bar` at $DIR/const_fn_ptr_fail2.rs:9:5 ... LL | const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday - | -------------- - | -note: the lint level is defined here - --> $DIR/const_fn_ptr_fail2.rs:4:10 - | -LL | #![allow(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 + | -------------- inside `Z` at $DIR/const_fn_ptr_fail2.rs:15:18 -Future breakage diagnostic: -warning: erroneous constant used - --> $DIR/const_fn_ptr_fail2.rs:19:5 - | -LL | assert_eq!(Y, 4); - | ^^^^^^^^^^^^^^^^ referenced constant has errors +warning: skipping const checks | -note: the lint level is defined here - --> $DIR/const_fn_ptr_fail2.rs:4:10 +help: skipping check that does not even have a feature gate + --> $DIR/const_fn_ptr_fail2.rs:9:5 | -LL | #![allow(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 - = note: this warning originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) +LL | x(y) + | ^^^^ -Future breakage diagnostic: -warning: erroneous constant used - --> $DIR/const_fn_ptr_fail2.rs:21:5 - | -LL | assert_eq!(Z, 4); - | ^^^^^^^^^^^^^^^^ referenced constant has errors - | -note: the lint level is defined here - --> $DIR/const_fn_ptr_fail2.rs:4:10 - | -LL | #![allow(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 - = note: this warning originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) +error: aborting due to 2 previous errors; 1 warning emitted +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/const_let.rs b/src/test/ui/consts/const-eval/const_let.rs index 18692dbce..1e2bcc55b 100644 --- a/src/test/ui/consts/const-eval/const_let.rs +++ b/src/test/ui/consts/const-eval/const_let.rs @@ -14,16 +14,16 @@ const X2: FakeNeedsDrop = { let x; x = FakeNeedsDrop; x }; // error const Y: FakeNeedsDrop = { let mut x = FakeNeedsDrop; x = FakeNeedsDrop; x }; -//~^ ERROR destructors cannot be evaluated at compile-time +//~^ ERROR destructor of // error const Y2: FakeNeedsDrop = { let mut x; x = FakeNeedsDrop; x = FakeNeedsDrop; x }; -//~^ ERROR destructors cannot be evaluated at compile-time +//~^ ERROR destructor of // error const Z: () = { let mut x = None; x = Some(FakeNeedsDrop); }; -//~^ ERROR destructors cannot be evaluated at compile-time +//~^ ERROR destructor of // error const Z2: () = { let mut x; x = None; x = Some(FakeNeedsDrop); }; -//~^ ERROR destructors cannot be evaluated at compile-time +//~^ ERROR destructor of diff --git a/src/test/ui/consts/const-eval/const_let.stderr b/src/test/ui/consts/const-eval/const_let.stderr index 47f39b703..63442f557 100644 --- a/src/test/ui/consts/const-eval/const_let.stderr +++ b/src/test/ui/consts/const-eval/const_let.stderr @@ -1,34 +1,34 @@ -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `FakeNeedsDrop` cannot be evaluated at compile-time --> $DIR/const_let.rs:16:32 | LL | const Y: FakeNeedsDrop = { let mut x = FakeNeedsDrop; x = FakeNeedsDrop; x }; | ^^^^^ - value is dropped here | | - | constants cannot evaluate destructors + | the destructor for this type cannot be evaluated in constants -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `FakeNeedsDrop` cannot be evaluated at compile-time --> $DIR/const_let.rs:20:33 | LL | const Y2: FakeNeedsDrop = { let mut x; x = FakeNeedsDrop; x = FakeNeedsDrop; x }; | ^^^^^ - value is dropped here | | - | constants cannot evaluate destructors + | the destructor for this type cannot be evaluated in constants -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Option` cannot be evaluated at compile-time --> $DIR/const_let.rs:24:21 | LL | const Z: () = { let mut x = None; x = Some(FakeNeedsDrop); }; | ^^^^^ - value is dropped here | | - | constants cannot evaluate destructors + | the destructor for this type cannot be evaluated in constants -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Option` cannot be evaluated at compile-time --> $DIR/const_let.rs:28:22 | LL | const Z2: () = { let mut x; x = None; x = Some(FakeNeedsDrop); }; | ^^^^^ - value is dropped here | | - | constants cannot evaluate destructors + | the destructor for this type cannot be evaluated in constants error: aborting due to 4 previous errors diff --git a/src/test/ui/consts/const-eval/const_panic_stability.e2018.stderr b/src/test/ui/consts/const-eval/const_panic_stability.e2018.stderr index f06dedc22..3553a18d3 100644 --- a/src/test/ui/consts/const-eval/const_panic_stability.e2018.stderr +++ b/src/test/ui/consts/const-eval/const_panic_stability.e2018.stderr @@ -4,9 +4,9 @@ warning: panic message is not a string literal LL | panic!({ "foo" }); | ^^^^^^^^^ | - = note: `#[warn(non_fmt_panics)]` on by default = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021 = note: for more information, see + = note: `#[warn(non_fmt_panics)]` on by default help: add a "{}" format string to `Display` the message | LL | panic!("{}", { "foo" }); diff --git a/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr b/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr index 168fa0ad0..12244450e 100644 --- a/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr +++ b/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr @@ -10,16 +10,6 @@ note: the trait `PartialEq<_>` is implemented for `*const i32`, but that impleme | LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; | ^^ - = help: the following other types implement trait `PartialEq`: - f32 - f64 - i128 - i16 - i32 - i64 - i8 - isize - and 6 others error[E0277]: can't compare `*const i32` with `_` in const contexts --> $DIR/const_raw_ptr_ops.rs:6:44 @@ -33,16 +23,6 @@ note: the trait `PartialEq<_>` is implemented for `*const i32`, but that impleme | LL | const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; | ^^ - = help: the following other types implement trait `PartialEq`: - f32 - f64 - i128 - i16 - i32 - i64 - i8 - isize - and 6 others error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/const-eval/erroneous-const.rs b/src/test/ui/consts/const-eval/erroneous-const.rs index bee5a7cb3..cf11531ba 100644 --- a/src/test/ui/consts/const-eval/erroneous-const.rs +++ b/src/test/ui/consts/const-eval/erroneous-const.rs @@ -1,11 +1,9 @@ //! Make sure we error on erroneous consts even if they are unused. -#![warn(const_err, unconditional_panic)] +#![allow(unconditional_panic)] struct PrintName(T); impl PrintName { - const VOID: () = [()][2]; //~WARN any use of this value will cause an error - //~^ WARN this operation will panic at runtime - //~| WARN this was previously accepted by the compiler but is being phased out + const VOID: () = [()][2]; //~ERROR evaluation of `PrintName::::VOID` failed } const fn no_codegen() { diff --git a/src/test/ui/consts/const-eval/erroneous-const.stderr b/src/test/ui/consts/const-eval/erroneous-const.stderr index adfb4cc61..33579135d 100644 --- a/src/test/ui/consts/const-eval/erroneous-const.stderr +++ b/src/test/ui/consts/const-eval/erroneous-const.stderr @@ -1,56 +1,21 @@ -warning: this operation will panic at runtime +error[E0080]: evaluation of `PrintName::::VOID` failed --> $DIR/erroneous-const.rs:6:22 | LL | const VOID: () = [()][2]; | ^^^^^^^ index out of bounds: the length is 1 but the index is 2 - | -note: the lint level is defined here - --> $DIR/erroneous-const.rs:2:20 - | -LL | #![warn(const_err, unconditional_panic)] - | ^^^^^^^^^^^^^^^^^^^ - -warning: any use of this value will cause an error - --> $DIR/erroneous-const.rs:6:22 - | -LL | const VOID: () = [()][2]; - | -------------- ^^^^^^^ index out of bounds: the length is 1 but the index is 2 - | -note: the lint level is defined here - --> $DIR/erroneous-const.rs:2:9 - | -LL | #![warn(const_err, unconditional_panic)] - | ^^^^^^^^^ - = 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 error[E0080]: could not evaluate static initializer - --> $DIR/erroneous-const.rs:15:17 + --> $DIR/erroneous-const.rs:13:17 | LL | let _ = PrintName::::VOID; | ^^^^^^^^^^^^^^^^^^^^ | | | referenced constant has errors - | inside `no_codegen::` at $DIR/erroneous-const.rs:15:17 + | inside `no_codegen::` at $DIR/erroneous-const.rs:13:17 ... LL | pub static FOO: () = no_codegen::(); - | ------------------- inside `FOO` at $DIR/erroneous-const.rs:19:22 + | ------------------- inside `FOO` at $DIR/erroneous-const.rs:17:22 -error: aborting due to previous error; 2 warnings emitted +error: aborting due to 2 previous errors 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/erroneous-const.rs:6:22 - | -LL | const VOID: () = [()][2]; - | -------------- ^^^^^^^ index out of bounds: the length is 1 but the index is 2 - | -note: the lint level is defined here - --> $DIR/erroneous-const.rs:2:9 - | -LL | #![warn(const_err, unconditional_panic)] - | ^^^^^^^^^ - = 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 - diff --git a/src/test/ui/consts/const-eval/erroneous-const2.rs b/src/test/ui/consts/const-eval/erroneous-const2.rs index aa0f093bf..2fbf7be88 100644 --- a/src/test/ui/consts/const-eval/erroneous-const2.rs +++ b/src/test/ui/consts/const-eval/erroneous-const2.rs @@ -1,11 +1,9 @@ //! Make sure we error on erroneous consts even if they are unused. -#![warn(const_err, unconditional_panic)] +#![allow(unconditional_panic)] struct PrintName(T); impl PrintName { - const VOID: () = [()][2]; //~WARN any use of this value will cause an error - //~^ WARN this operation will panic at runtime - //~| WARN this was previously accepted by the compiler but is being phased out + const VOID: () = [()][2]; //~ERROR evaluation of `PrintName::::VOID` failed } pub static FOO: () = { diff --git a/src/test/ui/consts/const-eval/erroneous-const2.stderr b/src/test/ui/consts/const-eval/erroneous-const2.stderr index e947d93e4..630b1cf16 100644 --- a/src/test/ui/consts/const-eval/erroneous-const2.stderr +++ b/src/test/ui/consts/const-eval/erroneous-const2.stderr @@ -1,50 +1,15 @@ -warning: this operation will panic at runtime +error[E0080]: evaluation of `PrintName::::VOID` failed --> $DIR/erroneous-const2.rs:6:22 | LL | const VOID: () = [()][2]; | ^^^^^^^ index out of bounds: the length is 1 but the index is 2 - | -note: the lint level is defined here - --> $DIR/erroneous-const2.rs:2:20 - | -LL | #![warn(const_err, unconditional_panic)] - | ^^^^^^^^^^^^^^^^^^^ - -warning: any use of this value will cause an error - --> $DIR/erroneous-const2.rs:6:22 - | -LL | const VOID: () = [()][2]; - | -------------- ^^^^^^^ index out of bounds: the length is 1 but the index is 2 - | -note: the lint level is defined here - --> $DIR/erroneous-const2.rs:2:9 - | -LL | #![warn(const_err, unconditional_panic)] - | ^^^^^^^^^ - = 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 error[E0080]: could not evaluate static initializer - --> $DIR/erroneous-const2.rs:15:17 + --> $DIR/erroneous-const2.rs:13:17 | LL | let _ = PrintName::::VOID; | ^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors -error: aborting due to previous error; 2 warnings emitted +error: aborting due to 2 previous errors 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/erroneous-const2.rs:6:22 - | -LL | const VOID: () = [()][2]; - | -------------- ^^^^^^^ index out of bounds: the length is 1 but the index is 2 - | -note: the lint level is defined here - --> $DIR/erroneous-const2.rs:2:9 - | -LL | #![warn(const_err, unconditional_panic)] - | ^^^^^^^^^ - = 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 - diff --git a/src/test/ui/consts/const-eval/format.rs b/src/test/ui/consts/const-eval/format.rs index e43633da3..3eef0d6c3 100644 --- a/src/test/ui/consts/const-eval/format.rs +++ b/src/test/ui/consts/const-eval/format.rs @@ -3,8 +3,6 @@ const fn failure() { //~^ ERROR cannot call non-const formatting macro in constant functions //~| ERROR erroneous constant used //~| ERROR erroneous constant used - //~| WARN this was previously accepted by the compiler - //~| WARN this was previously accepted by the compiler } const fn print() { @@ -14,8 +12,6 @@ const fn print() { //~| ERROR cannot call non-const fn `_print` in constant functions //~| ERROR erroneous constant used //~| ERROR erroneous constant used - //~| WARN this was previously accepted by the compiler - //~| WARN this was previously accepted by the compiler } fn main() {} diff --git a/src/test/ui/consts/const-eval/format.stderr b/src/test/ui/consts/const-eval/format.stderr index a476b0f58..64c769648 100644 --- a/src/test/ui/consts/const-eval/format.stderr +++ b/src/test/ui/consts/const-eval/format.stderr @@ -8,7 +8,7 @@ LL | panic!("{:?}", 0); = note: this error originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const formatting macro in constant functions - --> $DIR/format.rs:11:22 + --> $DIR/format.rs:9:22 | LL | println!("{:?}", 0); | ^ @@ -17,7 +17,7 @@ LL | println!("{:?}", 0); = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: `Arguments::<'a>::new_v1` is not yet stable as a const fn - --> $DIR/format.rs:11:5 + --> $DIR/format.rs:9:5 | LL | println!("{:?}", 0); | ^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | println!("{:?}", 0); = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const fn `_print` in constant functions - --> $DIR/format.rs:11:5 + --> $DIR/format.rs:9:5 | LL | println!("{:?}", 0); | ^^^^^^^^^^^^^^^^^^^ @@ -34,91 +34,35 @@ LL | println!("{:?}", 0); = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -error: erroneous constant used +error[E0080]: erroneous constant used --> $DIR/format.rs:2:12 | LL | panic!("{:?}", 0); | ^^^^^^ 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 -error: erroneous constant used +error[E0080]: erroneous constant used --> $DIR/format.rs:2:20 | LL | panic!("{:?}", 0); | ^ referenced constant has errors | - = 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 = note: this error originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error: erroneous constant used - --> $DIR/format.rs:11:14 +error[E0080]: erroneous constant used + --> $DIR/format.rs:9:14 | LL | println!("{:?}", 0); | ^^^^^^ referenced constant has errors - | - = 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 -error: erroneous constant used - --> $DIR/format.rs:11:22 +error[E0080]: erroneous constant used + --> $DIR/format.rs:9:22 | LL | println!("{:?}", 0); | ^ referenced constant has errors | - = 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 = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 8 previous errors -For more information about this error, try `rustc --explain E0015`. -Future incompatibility report: Future breakage diagnostic: -error: erroneous constant used - --> $DIR/format.rs:2:12 - | -LL | panic!("{:?}", 0); - | ^^^^^^ 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 - -Future breakage diagnostic: -error: erroneous constant used - --> $DIR/format.rs:2:20 - | -LL | panic!("{:?}", 0); - | ^ 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 - = note: this error originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) - -Future breakage diagnostic: -error: erroneous constant used - --> $DIR/format.rs:11:14 - | -LL | println!("{:?}", 0); - | ^^^^^^ 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 - -Future breakage diagnostic: -error: erroneous constant used - --> $DIR/format.rs:11:22 - | -LL | println!("{:?}", 0); - | ^ 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 - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) - +Some errors have detailed explanations: E0015, E0080. +For more information about an error, try `rustc --explain E0015`. diff --git a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr index f1a780926..a0f4519ea 100644 --- a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr +++ b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr @@ -2,7 +2,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/alloc_intrinsic_uninit.rs:8:1 | LL | const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) }; - | ^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized bytes, but expected initialized bytes + | ^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized memory, but expected an integer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { diff --git a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr index 2eb401226..d2bffa425 100644 --- a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr +++ b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr @@ -2,7 +2,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/alloc_intrinsic_uninit.rs:8:1 | LL | const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) }; - | ^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized bytes, but expected initialized bytes + | ^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized memory, but expected an integer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { diff --git a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs index 8064cc493..bc2ea3f18 100644 --- a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs +++ b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs @@ -1,21 +1,19 @@ // build-fail // Regression test for #66975 -#![warn(const_err, unconditional_panic)] +#![warn(unconditional_panic)] #![feature(never_type)] struct PrintName(T); impl PrintName { const VOID: ! = { let x = 0 * std::mem::size_of::(); [][x] }; - //~^ WARN any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of `PrintName::<()>::VOID` failed } fn f() { let _ = PrintName::::VOID; - //~^ ERROR erroneous constant encountered } pub fn main() { diff --git a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr index da4a21e08..8bcd03005 100644 --- a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr +++ b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr @@ -1,37 +1,15 @@ -warning: any use of this value will cause an error +error[E0080]: evaluation of `PrintName::<()>::VOID` failed --> $DIR/index-out-of-bounds-never-type.rs:10:61 | LL | const VOID: ! = { let x = 0 * std::mem::size_of::(); [][x] }; - | ------------- ^^^^^ index out of bounds: the length is 0 but the index is 0 - | -note: the lint level is defined here - --> $DIR/index-out-of-bounds-never-type.rs:4:9 - | -LL | #![warn(const_err, unconditional_panic)] - | ^^^^^^^^^ - = 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 + | ^^^^^ index out of bounds: the length is 0 but the index is 0 -error: erroneous constant encountered - --> $DIR/index-out-of-bounds-never-type.rs:17:13 +note: the above error was encountered while instantiating `fn f::<()>` + --> $DIR/index-out-of-bounds-never-type.rs:20:5 | -LL | let _ = PrintName::::VOID; - | ^^^^^^^^^^^^^^^^^^^^ +LL | f::<()>(); + | ^^^^^^^^^ -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/index-out-of-bounds-never-type.rs:10:61 - | -LL | const VOID: ! = { let x = 0 * std::mem::size_of::(); [][x] }; - | ------------- ^^^^^ index out of bounds: the length is 0 but the index is 0 - | -note: the lint level is defined here - --> $DIR/index-out-of-bounds-never-type.rs:4:9 - | -LL | #![warn(const_err, unconditional_panic)] - | ^^^^^^^^^ - = 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 +error: aborting due to previous error +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/infinite_loop.rs b/src/test/ui/consts/const-eval/infinite_loop.rs index 14a573ccf..4babc9a28 100644 --- a/src/test/ui/consts/const-eval/infinite_loop.rs +++ b/src/test/ui/consts/const-eval/infinite_loop.rs @@ -4,8 +4,8 @@ fn main() { let _ = [(); { let mut n = 113383; // #20 in https://oeis.org/A006884 while n != 0 { - n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; //~^ ERROR evaluation of constant value failed + n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; } n }]; diff --git a/src/test/ui/consts/const-eval/infinite_loop.stderr b/src/test/ui/consts/const-eval/infinite_loop.stderr index 3b5a0f22f..8b58cb279 100644 --- a/src/test/ui/consts/const-eval/infinite_loop.stderr +++ b/src/test/ui/consts/const-eval/infinite_loop.stderr @@ -1,8 +1,8 @@ error[E0080]: evaluation of constant value failed - --> $DIR/infinite_loop.rs:7:20 + --> $DIR/infinite_loop.rs:6:15 | -LL | n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; - | ^^^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`) +LL | while n != 0 { + | ^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`) error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/issue-100878.rs b/src/test/ui/consts/const-eval/issue-100878.rs new file mode 100644 index 000000000..353ce5050 --- /dev/null +++ b/src/test/ui/consts/const-eval/issue-100878.rs @@ -0,0 +1,8 @@ +// This checks that the const-eval ICE in issue #100878 does not recur. +// +// build-pass +pub fn bitshift_data(data: [u8; 1]) -> u8 { + data[0] << 8 +} + +fn main() {} diff --git a/src/test/ui/consts/const-eval/issue-43197.rs b/src/test/ui/consts/const-eval/issue-43197.rs index e15f8771d..145463f0a 100644 --- a/src/test/ui/consts/const-eval/issue-43197.rs +++ b/src/test/ui/consts/const-eval/issue-43197.rs @@ -1,23 +1,11 @@ -// build-fail - -#![warn(const_err)] - const fn foo(x: u32) -> u32 { x } fn main() { const X: u32 = 0 - 1; - //~^ WARN any use of this value will cause - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR constant const Y: u32 = foo(0 - 1); - //~^ WARN any use of this value will cause - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR constant println!("{} {}", X, Y); - //~^ ERROR evaluation of constant value failed - //~| ERROR evaluation of constant value failed - //~| WARN erroneous constant used [const_err] - //~| WARN erroneous constant used [const_err] - //~| WARN this was previously accepted by the compiler but is being phased out - //~| WARN this was previously accepted by the compiler but is being phased out } diff --git a/src/test/ui/consts/const-eval/issue-43197.stderr b/src/test/ui/consts/const-eval/issue-43197.stderr index 3f67c38f8..c59f13e48 100644 --- a/src/test/ui/consts/const-eval/issue-43197.stderr +++ b/src/test/ui/consts/const-eval/issue-43197.stderr @@ -1,120 +1,15 @@ -warning: any use of this value will cause an error - --> $DIR/issue-43197.rs:10:20 - | -LL | const X: u32 = 0 - 1; - | ------------ ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/issue-43197.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 - -warning: any use of this value will cause an error - --> $DIR/issue-43197.rs:13:24 - | -LL | const Y: u32 = foo(0 - 1); - | ------------ ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | - = 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 - error[E0080]: evaluation of constant value failed - --> $DIR/issue-43197.rs:16:23 - | -LL | println!("{} {}", X, Y); - | ^ referenced constant has errors - -warning: erroneous constant used - --> $DIR/issue-43197.rs:16:23 - | -LL | println!("{} {}", X, Y); - | ^ referenced constant has errors - | - = 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 - = note: this warning originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0080]: evaluation of constant value failed - --> $DIR/issue-43197.rs:16:26 - | -LL | println!("{} {}", X, Y); - | ^ referenced constant has errors - -warning: erroneous constant used - --> $DIR/issue-43197.rs:16:26 - | -LL | println!("{} {}", X, Y); - | ^ referenced constant has errors - | - = 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 - = note: this warning originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 2 previous errors; 4 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/issue-43197.rs:10:20 + --> $DIR/issue-43197.rs:6:20 | LL | const X: u32 = 0 - 1; - | ------------ ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/issue-43197.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 + | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow -Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/issue-43197.rs:13:24 +error[E0080]: evaluation of constant value failed + --> $DIR/issue-43197.rs:8:24 | LL | const Y: u32 = foo(0 - 1); - | ------------ ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/issue-43197.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 + | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow -Future breakage diagnostic: -warning: erroneous constant used - --> $DIR/issue-43197.rs:16:23 - | -LL | println!("{} {}", X, Y); - | ^ referenced constant has errors - | -note: the lint level is defined here - --> $DIR/issue-43197.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 - = note: this warning originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) - -Future breakage diagnostic: -warning: erroneous constant used - --> $DIR/issue-43197.rs:16:26 - | -LL | println!("{} {}", X, Y); - | ^ referenced constant has errors - | -note: the lint level is defined here - --> $DIR/issue-43197.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 - = note: this warning originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/issue-44578.rs b/src/test/ui/consts/const-eval/issue-44578.rs index a88e21970..2dbe1c2bd 100644 --- a/src/test/ui/consts/const-eval/issue-44578.rs +++ b/src/test/ui/consts/const-eval/issue-44578.rs @@ -1,7 +1,5 @@ // build-fail -#![allow(const_err)] - trait Foo { const AMT: usize; } @@ -12,7 +10,7 @@ enum Bar { } impl Foo for Bar { - const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; + const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; //~ERROR evaluation of ` as Foo>::AMT` failed } impl Foo for u8 { @@ -26,4 +24,5 @@ impl Foo for u16 { fn main() { println!("{}", as Foo>::AMT); //~^ ERROR evaluation of constant value failed + //~| ERROR erroneous constant used } diff --git a/src/test/ui/consts/const-eval/issue-44578.stderr b/src/test/ui/consts/const-eval/issue-44578.stderr index 4c27ceea1..963381b58 100644 --- a/src/test/ui/consts/const-eval/issue-44578.stderr +++ b/src/test/ui/consts/const-eval/issue-44578.stderr @@ -1,40 +1,23 @@ +error[E0080]: evaluation of ` as Foo>::AMT` failed + --> $DIR/issue-44578.rs:13:24 + | +LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 + error[E0080]: evaluation of constant value failed - --> $DIR/issue-44578.rs:27:20 + --> $DIR/issue-44578.rs:25:20 | LL | println!("{}", as Foo>::AMT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors -error: aborting due to previous error - -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/issue-44578.rs:15:24 - | -LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; - | ---------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 - | -note: the lint level is defined here - --> $DIR/issue-44578.rs:3:10 - | -LL | #![allow(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 - -Future breakage diagnostic: -warning: erroneous constant used - --> $DIR/issue-44578.rs:27:20 +error[E0080]: erroneous constant used + --> $DIR/issue-44578.rs:25:20 | LL | println!("{}", as Foo>::AMT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors | -note: the lint level is defined here - --> $DIR/issue-44578.rs:3:10 - | -LL | #![allow(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 - = note: this warning originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/issue-50814-2.rs b/src/test/ui/consts/const-eval/issue-50814-2.rs index 15f4de0ae..49d1d8ff0 100644 --- a/src/test/ui/consts/const-eval/issue-50814-2.rs +++ b/src/test/ui/consts/const-eval/issue-50814-2.rs @@ -11,8 +11,7 @@ trait Foo { struct A(T); impl Foo for A { - const BAR: usize = [5, 6, 7][T::BOO]; //~ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + const BAR: usize = [5, 6, 7][T::BOO]; //~ ERROR evaluation of ` as Foo<()>>::BAR` failed } fn foo() -> &'static usize { diff --git a/src/test/ui/consts/const-eval/issue-50814-2.stderr b/src/test/ui/consts/const-eval/issue-50814-2.stderr index cc19caca7..6604f2b9f 100644 --- a/src/test/ui/consts/const-eval/issue-50814-2.stderr +++ b/src/test/ui/consts/const-eval/issue-50814-2.stderr @@ -1,21 +1,17 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of ` as Foo<()>>::BAR` failed --> $DIR/issue-50814-2.rs:14:24 | LL | const BAR: usize = [5, 6, 7][T::BOO]; - | ---------------- ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 - | - = 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 + | ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 error[E0080]: evaluation of `foo::<()>` failed - --> $DIR/issue-50814-2.rs:19:6 + --> $DIR/issue-50814-2.rs:18:6 | LL | & as Foo>::BAR | ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors note: the above error was encountered while instantiating `fn foo::<()>` - --> $DIR/issue-50814-2.rs:31:22 + --> $DIR/issue-50814-2.rs:30:22 | LL | println!("{:x}", foo::<()>() as *const usize as usize); | ^^^^^^^^^^^ @@ -23,14 +19,3 @@ LL | println!("{:x}", foo::<()>() as *const usize as usize); error: aborting due to 2 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/issue-50814-2.rs:14:24 - | -LL | const BAR: usize = [5, 6, 7][T::BOO]; - | ---------------- ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 - | - = 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 - diff --git a/src/test/ui/consts/const-eval/issue-50814.rs b/src/test/ui/consts/const-eval/issue-50814.rs index 98229f919..5a587701f 100644 --- a/src/test/ui/consts/const-eval/issue-50814.rs +++ b/src/test/ui/consts/const-eval/issue-50814.rs @@ -13,8 +13,7 @@ struct Sum(A,B); impl Unsigned for Sum { const MAX: u8 = A::MAX + B::MAX; - //~^ ERROR any use of this value will cause an error [const_err] - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of ` as Unsigned>::MAX` failed } fn foo(_: T) -> &'static u8 { diff --git a/src/test/ui/consts/const-eval/issue-50814.stderr b/src/test/ui/consts/const-eval/issue-50814.stderr index 6ceef91a0..46dd2b89f 100644 --- a/src/test/ui/consts/const-eval/issue-50814.stderr +++ b/src/test/ui/consts/const-eval/issue-50814.stderr @@ -1,21 +1,17 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of ` as Unsigned>::MAX` failed --> $DIR/issue-50814.rs:15:21 | LL | const MAX: u8 = A::MAX + B::MAX; - | ------------- ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, 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 + | ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow error[E0080]: evaluation of `foo::` failed - --> $DIR/issue-50814.rs:21:6 + --> $DIR/issue-50814.rs:20:6 | LL | &Sum::::MAX | ^^^^^^^^^^^^^^^^^ referenced constant has errors note: the above error was encountered while instantiating `fn foo::` - --> $DIR/issue-50814.rs:26:5 + --> $DIR/issue-50814.rs:25:5 | LL | foo(0); | ^^^^^^ @@ -23,14 +19,3 @@ LL | foo(0); error: aborting due to 2 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/issue-50814.rs:15:21 - | -LL | const MAX: u8 = A::MAX + B::MAX; - | ------------- ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, 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 - diff --git a/src/test/ui/consts/const-eval/issue-65394.rs b/src/test/ui/consts/const-eval/issue-65394.rs index 2518e4ed4..e6639826c 100644 --- a/src/test/ui/consts/const-eval/issue-65394.rs +++ b/src/test/ui/consts/const-eval/issue-65394.rs @@ -4,7 +4,7 @@ // We will likely have to change this behavior before we allow `&mut` in a `const`. const _: Vec = { - let mut x = Vec::::new(); //~ ERROR destructors cannot be evaluated at compile-time + let mut x = Vec::::new(); //~ ERROR destructor of let r = &mut x; //~ ERROR mutable references are not allowed in constants let y = x; y diff --git a/src/test/ui/consts/const-eval/issue-65394.stderr b/src/test/ui/consts/const-eval/issue-65394.stderr index ec229d7f5..ae6f0e937 100644 --- a/src/test/ui/consts/const-eval/issue-65394.stderr +++ b/src/test/ui/consts/const-eval/issue-65394.stderr @@ -7,11 +7,11 @@ LL | let r = &mut x; = note: see issue #57349 for more information = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Vec` cannot be evaluated at compile-time --> $DIR/issue-65394.rs:7:9 | LL | let mut x = Vec::::new(); - | ^^^^^ constants cannot evaluate destructors + | ^^^^^ the destructor for this type cannot be evaluated in constants ... LL | }; | - value is dropped here diff --git a/src/test/ui/consts/const-eval/issue-91827-extern-types.rs b/src/test/ui/consts/const-eval/issue-91827-extern-types.rs index e1f5e8ae1..43c99799f 100644 --- a/src/test/ui/consts/const-eval/issue-91827-extern-types.rs +++ b/src/test/ui/consts/const-eval/issue-91827-extern-types.rs @@ -3,7 +3,6 @@ // Test that we can handle unsized types with an extern type tail part. // Regression test for issue #91827. -#![feature(const_ptr_offset_from)] #![feature(extern_types)] use std::ptr::addr_of; diff --git a/src/test/ui/consts/const-eval/livedrop.rs b/src/test/ui/consts/const-eval/livedrop.rs index 66b7d0580..543f1f0ec 100644 --- a/src/test/ui/consts/const-eval/livedrop.rs +++ b/src/test/ui/consts/const-eval/livedrop.rs @@ -1,6 +1,6 @@ const _: Option> = { let mut never_returned = Some(Vec::new()); - let mut always_returned = None; //~ ERROR destructors cannot be evaluated at compile-time + let mut always_returned = None; //~ ERROR destructor of let mut i = 0; loop { diff --git a/src/test/ui/consts/const-eval/livedrop.stderr b/src/test/ui/consts/const-eval/livedrop.stderr index 1e8b4230c..d04fdb70e 100644 --- a/src/test/ui/consts/const-eval/livedrop.stderr +++ b/src/test/ui/consts/const-eval/livedrop.stderr @@ -1,8 +1,8 @@ -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Option>` cannot be evaluated at compile-time --> $DIR/livedrop.rs:3:9 | LL | let mut always_returned = None; - | ^^^^^^^^^^^^^^^^^^^ constants cannot evaluate destructors + | ^^^^^^^^^^^^^^^^^^^ the destructor for this type cannot be evaluated in constants ... LL | always_returned = never_returned; | --------------- value is dropped here diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs index 80b0a1432..d2a840932 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs @@ -1,7 +1,6 @@ // build-fail // Regression test for #66975 -#![warn(const_err)] #![feature(never_type)] struct PrintName; diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr index b26286411..4204d302b 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -1,13 +1,13 @@ error[E0080]: evaluation of constant value failed - --> $DIR/panic-assoc-never-type.rs:10:21 + --> $DIR/panic-assoc-never-type.rs:9:21 | LL | const VOID: ! = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-assoc-never-type.rs:10:21 + | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-assoc-never-type.rs:9:21 | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: erroneous constant used - --> $DIR/panic-assoc-never-type.rs:15:13 + --> $DIR/panic-assoc-never-type.rs:14:13 | LL | let _ = PrintName::VOID; | ^^^^^^^^^^^^^^^ referenced constant has errors diff --git a/src/test/ui/consts/const-eval/panic-never-type.rs b/src/test/ui/consts/const-eval/panic-never-type.rs index a74d3ba29..a9e9026d9 100644 --- a/src/test/ui/consts/const-eval/panic-never-type.rs +++ b/src/test/ui/consts/const-eval/panic-never-type.rs @@ -1,5 +1,4 @@ // Regression test for #66975 -#![warn(const_err)] #![feature(never_type)] const VOID: ! = panic!(); diff --git a/src/test/ui/consts/const-eval/panic-never-type.stderr b/src/test/ui/consts/const-eval/panic-never-type.stderr index 9728aed07..6bff14a45 100644 --- a/src/test/ui/consts/const-eval/panic-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-never-type.stderr @@ -1,8 +1,8 @@ error[E0080]: evaluation of constant value failed - --> $DIR/panic-never-type.rs:5:17 + --> $DIR/panic-never-type.rs:4:17 | LL | const VOID: ! = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-never-type.rs:5:17 + | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-never-type.rs:4:17 | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/consts/const-eval/partial_ptr_overwrite.rs b/src/test/ui/consts/const-eval/partial_ptr_overwrite.rs index 07bca7d64..d6c768868 100644 --- a/src/test/ui/consts/const-eval/partial_ptr_overwrite.rs +++ b/src/test/ui/consts/const-eval/partial_ptr_overwrite.rs @@ -5,9 +5,8 @@ const PARTIAL_OVERWRITE: () = { let mut p = &42; unsafe { let ptr: *mut _ = &mut p; - *(ptr as *mut u8) = 123; //~ ERROR any use of this value + *(ptr as *mut u8) = 123; //~ ERROR constant //~| unable to overwrite parts of a pointer - //~| WARN previously accepted } let x = *p; }; diff --git a/src/test/ui/consts/const-eval/partial_ptr_overwrite.stderr b/src/test/ui/consts/const-eval/partial_ptr_overwrite.stderr index 75e50a27b..13ca4379b 100644 --- a/src/test/ui/consts/const-eval/partial_ptr_overwrite.stderr +++ b/src/test/ui/consts/const-eval/partial_ptr_overwrite.stderr @@ -1,33 +1,12 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/partial_ptr_overwrite.rs:8:9 | -LL | const PARTIAL_OVERWRITE: () = { - | --------------------------- -... LL | *(ptr as *mut u8) = 123; | ^^^^^^^^^^^^^^^^^^^^^^^ unable to overwrite parts of a pointer in memory at alloc4 | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error: aborting due to previous error -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/partial_ptr_overwrite.rs:8:9 - | -LL | const PARTIAL_OVERWRITE: () = { - | --------------------------- -... -LL | *(ptr as *mut u8) = 123; - | ^^^^^^^^^^^^^^^^^^^^^^^ unable to overwrite parts of a pointer in memory at alloc4 - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs b/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs index 1fc7af637..656dd33e1 100644 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs +++ b/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs @@ -1,5 +1,3 @@ -#![allow(const_err)] - #[repr(C)] union Bar { a: &'static u8, diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr b/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr index c6ca30e09..596fa090d 100644 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr +++ b/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_fn_fail.rs:19:27 + --> $DIR/promoted_const_fn_fail.rs:17:27 | LL | let x: &'static u8 = &(bar() + 1); | ----------- ^^^^^^^^^^^ creates a temporary which is freed while still in use diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.rs b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.rs index c53424664..5009dbcb9 100644 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.rs +++ b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.rs @@ -1,5 +1,3 @@ -#![deny(const_err)] - #[repr(C)] union Bar { a: &'static u8, diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr index c6275a835..63dc43a41 100644 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr +++ b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_fn_fail_deny_const_err.rs:20:27 + --> $DIR/promoted_const_fn_fail_deny_const_err.rs:18:27 | LL | let x: &'static u8 = &(bar() + 1); | ----------- ^^^^^^^^^^^ creates a temporary which is freed while still in use diff --git a/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr b/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr index cfca8ef07..2a254bfde 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr @@ -5,111 +5,40 @@ LL | 0 - 1 | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow | note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:20 + --> $DIR/promoted_errors.rs:11:9 | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^^^^^^^^^^^ +LL | #![warn(arithmetic_overflow, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:21:5 + --> $DIR/promoted_errors.rs:19:5 | LL | 1 / 0 | ^^^^^ attempt to divide `1_i32` by zero | note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:41 + --> $DIR/promoted_errors.rs:11:30 | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^^^^^^^^^^^ +LL | #![warn(arithmetic_overflow, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:27:5 + --> $DIR/promoted_errors.rs:23:5 | LL | 1 / (1 - 1) | ^^^^^^^^^^^ attempt to divide `1_i32` by zero warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:31:5 + --> $DIR/promoted_errors.rs:27:5 | LL | 1 / (false as i32) | ^^^^^^^^^^^^^^^^^^ attempt to divide `1_i32` by zero warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:35:5 + --> $DIR/promoted_errors.rs:31:5 | LL | [1, 2, 3][4] | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:15:5 - | -LL | 0 - 1 - | ^^^^^ - | | - | attempt to compute `0_u32 - 1_u32`, which would overflow - | inside `overflow` at $DIR/promoted_errors.rs:15:5 - | inside `X` at $DIR/promoted_errors.rs:43:29 -... -LL | const X: () = { - | ----------- - | -note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:9 - | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^ - = 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 - -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:43:28 - | -LL | const X: () = { - | ----------- -LL | let _x: &'static u32 = &overflow(); - | ^^^^^^^^^^^ referenced constant has errors - | - = 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 - -warning: 7 warnings emitted - -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:15:5 - | -LL | 0 - 1 - | ^^^^^ - | | - | attempt to compute `0_u32 - 1_u32`, which would overflow - | inside `overflow` at $DIR/promoted_errors.rs:15:5 - | inside `X` at $DIR/promoted_errors.rs:43:29 -... -LL | const X: () = { - | ----------- - | -note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:9 - | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^ - = 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 - -Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:43:28 - | -LL | const X: () = { - | ----------- -LL | let _x: &'static u32 = &overflow(); - | ^^^^^^^^^^^ referenced constant has errors - | -note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:9 - | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^ - = 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 +warning: 5 warnings emitted diff --git a/src/test/ui/consts/const-eval/promoted_errors.opt.stderr b/src/test/ui/consts/const-eval/promoted_errors.opt.stderr index 984484a85..2a254bfde 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.opt.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.opt.stderr @@ -5,113 +5,40 @@ LL | 0 - 1 | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow | note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:20 + --> $DIR/promoted_errors.rs:11:9 | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^^^^^^^^^^^ +LL | #![warn(arithmetic_overflow, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:21:5 + --> $DIR/promoted_errors.rs:19:5 | LL | 1 / 0 | ^^^^^ attempt to divide `1_i32` by zero | note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:41 + --> $DIR/promoted_errors.rs:11:30 | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^^^^^^^^^^^ +LL | #![warn(arithmetic_overflow, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:27:5 + --> $DIR/promoted_errors.rs:23:5 | LL | 1 / (1 - 1) | ^^^^^^^^^^^ attempt to divide `1_i32` by zero warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:31:5 + --> $DIR/promoted_errors.rs:27:5 | LL | 1 / (false as i32) | ^^^^^^^^^^^^^^^^^^ attempt to divide `1_i32` by zero warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:35:5 + --> $DIR/promoted_errors.rs:31:5 | LL | [1, 2, 3][4] | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:21:5 - | -LL | 1 / 0 - | ^^^^^ - | | - | attempt to divide `1_i32` by zero - | inside `div_by_zero1` at $DIR/promoted_errors.rs:21:5 - | inside `X` at $DIR/promoted_errors.rs:46:29 -... -LL | const X: () = { - | ----------- - | -note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:9 - | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^ - = 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 - -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:46:28 - | -LL | const X: () = { - | ----------- -... -LL | let _x: &'static i32 = &div_by_zero1(); - | ^^^^^^^^^^^^^^^ referenced constant has errors - | - = 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 - -warning: 7 warnings emitted - -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:21:5 - | -LL | 1 / 0 - | ^^^^^ - | | - | attempt to divide `1_i32` by zero - | inside `div_by_zero1` at $DIR/promoted_errors.rs:21:5 - | inside `X` at $DIR/promoted_errors.rs:46:29 -... -LL | const X: () = { - | ----------- - | -note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:9 - | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^ - = 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 - -Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:46:28 - | -LL | const X: () = { - | ----------- -... -LL | let _x: &'static i32 = &div_by_zero1(); - | ^^^^^^^^^^^^^^^ referenced constant has errors - | -note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:9 - | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^ - = 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 +warning: 5 warnings emitted diff --git a/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr b/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr index cfca8ef07..2a254bfde 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr @@ -5,111 +5,40 @@ LL | 0 - 1 | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow | note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:20 + --> $DIR/promoted_errors.rs:11:9 | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^^^^^^^^^^^ +LL | #![warn(arithmetic_overflow, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:21:5 + --> $DIR/promoted_errors.rs:19:5 | LL | 1 / 0 | ^^^^^ attempt to divide `1_i32` by zero | note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:41 + --> $DIR/promoted_errors.rs:11:30 | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^^^^^^^^^^^ +LL | #![warn(arithmetic_overflow, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:27:5 + --> $DIR/promoted_errors.rs:23:5 | LL | 1 / (1 - 1) | ^^^^^^^^^^^ attempt to divide `1_i32` by zero warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:31:5 + --> $DIR/promoted_errors.rs:27:5 | LL | 1 / (false as i32) | ^^^^^^^^^^^^^^^^^^ attempt to divide `1_i32` by zero warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:35:5 + --> $DIR/promoted_errors.rs:31:5 | LL | [1, 2, 3][4] | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:15:5 - | -LL | 0 - 1 - | ^^^^^ - | | - | attempt to compute `0_u32 - 1_u32`, which would overflow - | inside `overflow` at $DIR/promoted_errors.rs:15:5 - | inside `X` at $DIR/promoted_errors.rs:43:29 -... -LL | const X: () = { - | ----------- - | -note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:9 - | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^ - = 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 - -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:43:28 - | -LL | const X: () = { - | ----------- -LL | let _x: &'static u32 = &overflow(); - | ^^^^^^^^^^^ referenced constant has errors - | - = 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 - -warning: 7 warnings emitted - -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:15:5 - | -LL | 0 - 1 - | ^^^^^ - | | - | attempt to compute `0_u32 - 1_u32`, which would overflow - | inside `overflow` at $DIR/promoted_errors.rs:15:5 - | inside `X` at $DIR/promoted_errors.rs:43:29 -... -LL | const X: () = { - | ----------- - | -note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:9 - | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^ - = 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 - -Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:43:28 - | -LL | const X: () = { - | ----------- -LL | let _x: &'static u32 = &overflow(); - | ^^^^^^^^^^^ referenced constant has errors - | -note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:9 - | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^ - = 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 +warning: 5 warnings emitted diff --git a/src/test/ui/consts/const-eval/promoted_errors.rs b/src/test/ui/consts/const-eval/promoted_errors.rs index eb891de33..2c42d0356 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.rs +++ b/src/test/ui/consts/const-eval/promoted_errors.rs @@ -8,20 +8,16 @@ //! This test ensures that when we promote code that fails to evaluate, the build still succeeds. -#![warn(const_err, arithmetic_overflow, unconditional_panic)] +#![warn(arithmetic_overflow, unconditional_panic)] // The only way to have promoteds that fail is in `const fn` called from `const`/`static`. const fn overflow() -> u32 { 0 - 1 - //[opt_with_overflow_checks,noopt]~^ WARN any use of this value will cause an error - //[opt_with_overflow_checks,noopt]~| WARN this was previously accepted by the compiler - //~^^^ WARN this arithmetic operation will overflow + //~^ WARN this arithmetic operation will overflow } const fn div_by_zero1() -> i32 { 1 / 0 - //[opt]~^ WARN any use of this value will cause an error - //[opt]~| WARN this was previously accepted by the compiler but is being phased out - //~^^^ WARN this operation will panic at runtime + //~^ WARN this operation will panic at runtime } const fn div_by_zero2() -> i32 { 1 / (1 - 1) @@ -36,21 +32,6 @@ const fn oob() -> i32 { //~^ WARN this operation will panic at runtime } -// An unused constant containing failing promoteds. -// This should work as long as `const_err` can be turned into just a warning; -// once it turns into a hard error, just remove `X`. -const X: () = { - let _x: &'static u32 = &overflow(); - //[opt_with_overflow_checks,noopt]~^ WARN any use of this value will cause an error - //[opt_with_overflow_checks,noopt]~| WARN this was previously accepted by the compiler - let _x: &'static i32 = &div_by_zero1(); - //[opt]~^ WARN any use of this value will cause an error - //[opt]~| WARN this was previously accepted by the compiler but is being phased out - let _x: &'static i32 = &div_by_zero2(); - let _x: &'static i32 = &div_by_zero3(); - let _x: &'static i32 = &oob(); -}; - const fn mk_false() -> bool { false } // An actually used constant referencing failing promoteds in dead code. diff --git a/src/test/ui/consts/const-eval/pub_const_err.rs b/src/test/ui/consts/const-eval/pub_const_err.rs deleted file mode 100644 index 5faacd556..000000000 --- a/src/test/ui/consts/const-eval/pub_const_err.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-pass -#![warn(const_err)] - -#![crate_type = "lib"] - -pub const Z: u32 = 0 - 1; -//~^ WARN any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out - -pub type Foo = [i32; 0 - 1]; diff --git a/src/test/ui/consts/const-eval/pub_const_err.stderr b/src/test/ui/consts/const-eval/pub_const_err.stderr deleted file mode 100644 index 36197a7ab..000000000 --- a/src/test/ui/consts/const-eval/pub_const_err.stderr +++ /dev/null @@ -1,31 +0,0 @@ -warning: any use of this value will cause an error - --> $DIR/pub_const_err.rs:6:20 - | -LL | pub const Z: u32 = 0 - 1; - | ---------------- ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/pub_const_err.rs:2: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 - -warning: 1 warning emitted - -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/pub_const_err.rs:6:20 - | -LL | pub const Z: u32 = 0 - 1; - | ---------------- ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/pub_const_err.rs:2: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 - diff --git a/src/test/ui/consts/const-eval/pub_const_err_bin.rs b/src/test/ui/consts/const-eval/pub_const_err_bin.rs deleted file mode 100644 index 82eae2512..000000000 --- a/src/test/ui/consts/const-eval/pub_const_err_bin.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-pass -#![warn(const_err)] - -pub const Z: u32 = 0 - 1; -//~^ WARN any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out - -pub type Foo = [i32; 0 - 1]; - -fn main() {} diff --git a/src/test/ui/consts/const-eval/pub_const_err_bin.stderr b/src/test/ui/consts/const-eval/pub_const_err_bin.stderr deleted file mode 100644 index 2eef3b8f5..000000000 --- a/src/test/ui/consts/const-eval/pub_const_err_bin.stderr +++ /dev/null @@ -1,31 +0,0 @@ -warning: any use of this value will cause an error - --> $DIR/pub_const_err_bin.rs:4:20 - | -LL | pub const Z: u32 = 0 - 1; - | ---------------- ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/pub_const_err_bin.rs:2: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 - -warning: 1 warning emitted - -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/pub_const_err_bin.rs:4:20 - | -LL | pub const Z: u32 = 0 - 1; - | ---------------- ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/pub_const_err_bin.rs:2: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 - diff --git a/src/test/ui/consts/const-eval/ref_to_int_match.32bit.stderr b/src/test/ui/consts/const-eval/ref_to_int_match.32bit.stderr index 30935e415..032ceb246 100644 --- a/src/test/ui/consts/const-eval/ref_to_int_match.32bit.stderr +++ b/src/test/ui/consts/const-eval/ref_to_int_match.32bit.stderr @@ -1,12 +1,9 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/ref_to_int_match.rs:25:27 | LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; - | -------------- ^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -24,16 +21,4 @@ LL | 10..=BAR => {}, error: aborting due to 3 previous errors -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ref_to_int_match.rs:25:27 - | -LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; - | -------------- ^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/ref_to_int_match.64bit.stderr b/src/test/ui/consts/const-eval/ref_to_int_match.64bit.stderr index 30935e415..032ceb246 100644 --- a/src/test/ui/consts/const-eval/ref_to_int_match.64bit.stderr +++ b/src/test/ui/consts/const-eval/ref_to_int_match.64bit.stderr @@ -1,12 +1,9 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/ref_to_int_match.rs:25:27 | LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; - | -------------- ^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -24,16 +21,4 @@ LL | 10..=BAR => {}, error: aborting due to 3 previous errors -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ref_to_int_match.rs:25:27 - | -LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; - | -------------- ^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/ref_to_int_match.rs b/src/test/ui/consts/const-eval/ref_to_int_match.rs index 3f342d916..70c6e7d94 100644 --- a/src/test/ui/consts/const-eval/ref_to_int_match.rs +++ b/src/test/ui/consts/const-eval/ref_to_int_match.rs @@ -23,5 +23,4 @@ type Int = u64; type Int = u32; const BAR: Int = unsafe { Foo { r: &42 }.f }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR constant diff --git a/src/test/ui/consts/const-eval/ub-enum-overwrite.rs b/src/test/ui/consts/const-eval/ub-enum-overwrite.rs index c56778492..086a1001d 100644 --- a/src/test/ui/consts/const-eval/ub-enum-overwrite.rs +++ b/src/test/ui/consts/const-eval/ub-enum-overwrite.rs @@ -6,12 +6,13 @@ enum E { } const _: u8 = { - //~^ ERROR is undefined behavior let mut e = E::A(1); let p = if let E::A(x) = &mut e { x as *mut u8 } else { unreachable!() }; // Make sure overwriting `e` uninitializes other bytes e = E::B; unsafe { *p } + //~^ ERROR evaluation of constant value failed + //~| uninitialized }; fn main() {} diff --git a/src/test/ui/consts/const-eval/ub-enum-overwrite.stderr b/src/test/ui/consts/const-eval/ub-enum-overwrite.stderr index 8560112ae..5750212b4 100644 --- a/src/test/ui/consts/const-eval/ub-enum-overwrite.stderr +++ b/src/test/ui/consts/const-eval/ub-enum-overwrite.stderr @@ -1,13 +1,8 @@ -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum-overwrite.rs:8:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-enum-overwrite.rs:13:14 | -LL | const _: u8 = { - | ^^^^^^^^^^^ constructing invalid value: encountered uninitialized bytes, but expected initialized bytes - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 1, align: 1) { - __ │ ░ - } +LL | unsafe { *p } + | ^^ using uninitialized data, but this operation requires initialized memory error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/ub-enum.32bit.stderr b/src/test/ui/consts/const-eval/ub-enum.32bit.stderr index ce3bc9474..93bc96e67 100644 --- a/src/test/ui/consts/const-eval/ub-enum.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-enum.32bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:23:1 + --> $DIR/ub-enum.rs:24:1 | LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered 0x00000001, but expected a valid enum tag @@ -9,31 +9,26 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; 01 00 00 00 │ .... } -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:26:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-enum.rs:27:1 | LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:30:1 | LL | const BAD_ENUM_WRAPPED: Wrap = unsafe { mem::transmute(&1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:43:1 + --> $DIR/ub-enum.rs:42:1 | LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered 0x00000000, but expected a valid enum tag @@ -43,52 +38,41 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; 00 00 00 00 │ .... } -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:45:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-enum.rs:44:1 | LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:49:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-enum.rs:47:1 | LL | const BAD_ENUM2_WRAPPED: Wrap = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:59:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-enum.rs:56:42 | LL | const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized bytes, but expected initialized bytes - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 4, align: 4) { - __ __ __ __ │ ░░░░ - } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:63:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-enum.rs:61:1 | LL | const BAD_ENUM2_OPTION_PTR: Option = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:81:1 + --> $DIR/ub-enum.rs:78:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a value of the never type `!` @@ -99,7 +83,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:83:1 + --> $DIR/ub-enum.rs:80:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a value of uninhabited type Never @@ -110,7 +94,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:91:1 + --> $DIR/ub-enum.rs:88:1 | LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) @@ -121,13 +105,13 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran } error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:96:77 + --> $DIR/ub-enum.rs:93:77 | LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; | ^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:98:77 + --> $DIR/ub-enum.rs:95:77 | LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; | ^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type @@ -135,68 +119,3 @@ LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { error: aborting due to 13 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/ub-enum.rs:26:1 - | -LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:30:1 - | -LL | const BAD_ENUM_WRAPPED: Wrap = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:45:1 - | -LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:49:1 - | -LL | const BAD_ENUM2_WRAPPED: Wrap = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:63:1 - | -LL | const BAD_ENUM2_OPTION_PTR: Option = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - diff --git a/src/test/ui/consts/const-eval/ub-enum.64bit.stderr b/src/test/ui/consts/const-eval/ub-enum.64bit.stderr index d8fc20c98..280ba25a8 100644 --- a/src/test/ui/consts/const-eval/ub-enum.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-enum.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:23:1 + --> $DIR/ub-enum.rs:24:1 | LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered 0x0000000000000001, but expected a valid enum tag @@ -9,31 +9,26 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; 01 00 00 00 00 00 00 00 │ ........ } -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:26:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-enum.rs:27:1 | LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:30:1 | LL | const BAD_ENUM_WRAPPED: Wrap = unsafe { mem::transmute(&1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:43:1 + --> $DIR/ub-enum.rs:42:1 | LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered 0x0000000000000000, but expected a valid enum tag @@ -43,52 +38,41 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; 00 00 00 00 00 00 00 00 │ ........ } -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:45:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-enum.rs:44:1 | LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:49:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-enum.rs:47:1 | LL | const BAD_ENUM2_WRAPPED: Wrap = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:59:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-enum.rs:56:42 | LL | const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized bytes, but expected initialized bytes - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 8, align: 8) { - __ __ __ __ __ __ __ __ │ ░░░░░░░░ - } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:63:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-enum.rs:61:1 | LL | const BAD_ENUM2_OPTION_PTR: Option = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:81:1 + --> $DIR/ub-enum.rs:78:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a value of the never type `!` @@ -99,7 +83,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:83:1 + --> $DIR/ub-enum.rs:80:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a value of uninhabited type Never @@ -110,7 +94,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:91:1 + --> $DIR/ub-enum.rs:88:1 | LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) @@ -121,13 +105,13 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran } error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:96:77 + --> $DIR/ub-enum.rs:93:77 | LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; | ^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:98:77 + --> $DIR/ub-enum.rs:95:77 | LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; | ^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type @@ -135,68 +119,3 @@ LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { error: aborting due to 13 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/ub-enum.rs:26:1 - | -LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:30:1 - | -LL | const BAD_ENUM_WRAPPED: Wrap = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:45:1 - | -LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:49:1 - | -LL | const BAD_ENUM2_WRAPPED: Wrap = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:63:1 - | -LL | const BAD_ENUM2_OPTION_PTR: Option = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - diff --git a/src/test/ui/consts/const-eval/ub-enum.rs b/src/test/ui/consts/const-eval/ub-enum.rs index d8d2a499b..6935be2f9 100644 --- a/src/test/ui/consts/const-eval/ub-enum.rs +++ b/src/test/ui/consts/const-eval/ub-enum.rs @@ -1,5 +1,6 @@ // stderr-per-bitwidth #![feature(never_type)] +#![allow(invalid_value)] use std::mem; @@ -24,12 +25,10 @@ const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; //~^ ERROR is undefined behavior const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed const BAD_ENUM_WRAPPED: Wrap = unsafe { mem::transmute(&1) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed // # simple enum with discriminant 2 @@ -43,12 +42,10 @@ enum Enum2 { const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; //~^ ERROR is undefined behavior const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed // something wrapping the enum so that we test layout first, not enum const BAD_ENUM2_WRAPPED: Wrap = unsafe { mem::transmute(&0) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed // Undef enum discriminant. #[repr(C)] @@ -57,12 +54,12 @@ union MaybeUninit { init: T, } const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR is undefined behavior +//~^ ERROR evaluation of constant value failed +//~| uninitialized // Pointer value in an enum with a niche that is not just 0. const BAD_ENUM2_OPTION_PTR: Option = unsafe { mem::transmute(&0) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed // # valid discriminant for uninhabited variant @@ -92,7 +89,7 @@ const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute //~^ ERROR is undefined behavior // All variants are uninhabited but also have data. -// Use `0` as constant to make behavior endianess-independent. +// Use `0` as constant to make behavior endianness-independent. const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; //~^ ERROR evaluation of constant value failed const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; diff --git a/src/test/ui/consts/const-eval/ub-int-array.32bit.stderr b/src/test/ui/consts/const-eval/ub-int-array.32bit.stderr index 8eece9e30..edcde13b0 100644 --- a/src/test/ui/consts/const-eval/ub-int-array.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-int-array.32bit.stderr @@ -1,35 +1,20 @@ -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:14:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-int-array.rs:15:9 | -LL | const UNINIT_INT_0: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered uninitialized bytes - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 12, align: 4) { - __ __ __ __ 01 00 00 00 02 00 00 00 │ ░░░░........ - } +LL | MaybeUninit { uninit: () }.init, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:23:1 - | -LL | const UNINIT_INT_1: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [1]: encountered uninitialized bytes +error[E0080]: evaluation of constant value failed + --> $DIR/ub-int-array.rs:30:13 | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 12, align: 4) { - 00 00 00 00 01 __ 01 01 02 02 __ 02 │ .....░....░. - } +LL | MaybeUninit { uninit: () }.init, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:43:1 - | -LL | const UNINIT_INT_2: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [2]: encountered uninitialized bytes +error[E0080]: evaluation of constant value failed + --> $DIR/ub-int-array.rs:56:13 | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 12, align: 4) { - 00 00 00 00 01 01 01 01 02 02 02 __ │ ...........░ - } +LL | MaybeUninit { uninit: () }.init, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error: aborting due to 3 previous errors diff --git a/src/test/ui/consts/const-eval/ub-int-array.64bit.stderr b/src/test/ui/consts/const-eval/ub-int-array.64bit.stderr index 8eece9e30..edcde13b0 100644 --- a/src/test/ui/consts/const-eval/ub-int-array.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-int-array.64bit.stderr @@ -1,35 +1,20 @@ -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:14:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-int-array.rs:15:9 | -LL | const UNINIT_INT_0: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered uninitialized bytes - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 12, align: 4) { - __ __ __ __ 01 00 00 00 02 00 00 00 │ ░░░░........ - } +LL | MaybeUninit { uninit: () }.init, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:23:1 - | -LL | const UNINIT_INT_1: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [1]: encountered uninitialized bytes +error[E0080]: evaluation of constant value failed + --> $DIR/ub-int-array.rs:30:13 | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 12, align: 4) { - 00 00 00 00 01 __ 01 01 02 02 __ 02 │ .....░....░. - } +LL | MaybeUninit { uninit: () }.init, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:43:1 - | -LL | const UNINIT_INT_2: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [2]: encountered uninitialized bytes +error[E0080]: evaluation of constant value failed + --> $DIR/ub-int-array.rs:56:13 | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 12, align: 4) { - 00 00 00 00 01 01 01 01 02 02 02 __ │ ...........░ - } +LL | MaybeUninit { uninit: () }.init, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error: aborting due to 3 previous errors diff --git a/src/test/ui/consts/const-eval/ub-int-array.rs b/src/test/ui/consts/const-eval/ub-int-array.rs index 1221f71d1..a68d3fb17 100644 --- a/src/test/ui/consts/const-eval/ub-int-array.rs +++ b/src/test/ui/consts/const-eval/ub-int-array.rs @@ -1,4 +1,3 @@ -#![allow(const_err)] // make sure we cannot allow away the errors tested here // stderr-per-bitwidth //! Test the "array of int" fast path in validity checking, and in particular whether it //! points at the right array element. @@ -12,17 +11,15 @@ union MaybeUninit { } const UNINIT_INT_0: [u32; 3] = unsafe { -//~^ ERROR it is undefined behavior to use this value -//~| constructing invalid value at [0]: encountered uninitialized bytes [ MaybeUninit { uninit: () }.init, + //~^ ERROR evaluation of constant value failed + //~| uninitialized 1, 2, ] }; const UNINIT_INT_1: [u32; 3] = unsafe { -//~^ ERROR it is undefined behavior to use this value -//~| constructing invalid value at [1]: encountered uninitialized bytes mem::transmute( [ 0u8, @@ -31,6 +28,8 @@ const UNINIT_INT_1: [u32; 3] = unsafe { 0u8, 1u8, MaybeUninit { uninit: () }.init, + //~^ ERROR evaluation of constant value failed + //~| uninitialized 1u8, 1u8, 2u8, @@ -41,8 +40,6 @@ const UNINIT_INT_1: [u32; 3] = unsafe { ) }; const UNINIT_INT_2: [u32; 3] = unsafe { -//~^ ERROR it is undefined behavior to use this value -//~| constructing invalid value at [2]: encountered uninitialized bytes mem::transmute( [ 0u8, @@ -57,6 +54,8 @@ const UNINIT_INT_2: [u32; 3] = unsafe { 2u8, 2u8, MaybeUninit { uninit: () }.init, + //~^ ERROR evaluation of constant value failed + //~| uninitialized ] ) }; diff --git a/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr b/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr index d450a814c..dbd05b8f4 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr @@ -10,13 +10,13 @@ LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-nonnull.rs:19:30 + --> $DIR/ub-nonnull.rs:18:30 | LL | let out_of_bounds_ptr = &ptr[255]; | ^^^^^^^^ dereferencing pointer failed: alloc11 has size 1, so pointer to 256 bytes starting at offset 0 is out-of-bounds error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:23:1 + --> $DIR/ub-nonnull.rs:22:1 | LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 @@ -27,7 +27,7 @@ LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:25:1 + --> $DIR/ub-nonnull.rs:24:1 | LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 @@ -37,16 +37,11 @@ LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:33:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-nonnull.rs:32:36 | LL | const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered uninitialized bytes, but expected initialized bytes - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 1, align: 1) { - __ │ ░ - } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value --> $DIR/ub-nonnull.rs:41:1 diff --git a/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr b/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr index ed0d91aab..5a1ac09bd 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr @@ -10,13 +10,13 @@ LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-nonnull.rs:19:30 + --> $DIR/ub-nonnull.rs:18:30 | LL | let out_of_bounds_ptr = &ptr[255]; | ^^^^^^^^ dereferencing pointer failed: alloc11 has size 1, so pointer to 256 bytes starting at offset 0 is out-of-bounds error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:23:1 + --> $DIR/ub-nonnull.rs:22:1 | LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 @@ -27,7 +27,7 @@ LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:25:1 + --> $DIR/ub-nonnull.rs:24:1 | LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 @@ -37,16 +37,11 @@ LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:33:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-nonnull.rs:32:36 | LL | const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered uninitialized bytes, but expected initialized bytes - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 1, align: 1) { - __ │ ░ - } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value --> $DIR/ub-nonnull.rs:41:1 diff --git a/src/test/ui/consts/const-eval/ub-nonnull.rs b/src/test/ui/consts/const-eval/ub-nonnull.rs index 259707b80..d22a99cd0 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.rs +++ b/src/test/ui/consts/const-eval/ub-nonnull.rs @@ -1,6 +1,6 @@ // stderr-per-bitwidth #![feature(rustc_attrs)] -#![allow(const_err, invalid_value)] // make sure we cannot allow away the errors tested here +#![allow(invalid_value)] // make sure we cannot allow away the errors tested here use std::mem; use std::ptr::NonNull; @@ -12,7 +12,6 @@ const NON_NULL_PTR: NonNull = unsafe { mem::transmute(&1) }; const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; //~^ ERROR it is undefined behavior to use this value -#[deny(const_err)] // this triggers a `const_err` so validation does not even happen const OUT_OF_BOUNDS_PTR: NonNull = { unsafe { let ptr: &[u8; 256] = mem::transmute(&0u8); // &0 gets promoted so it does not dangle // Use address-of-element for pointer arithmetic. This could wrap around to null! @@ -31,7 +30,8 @@ union MaybeUninit { init: T, } const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR evaluation of constant value failed +//~| uninitialized // Also test other uses of rustc_layout_scalar_valid_range_start diff --git a/src/test/ui/consts/const-eval/ub-ref-ptr.32bit.stderr b/src/test/ui/consts/const-eval/ub-ref-ptr.32bit.stderr index e86b37929..6f5c028cb 100644 --- a/src/test/ui/consts/const-eval/ub-ref-ptr.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-ref-ptr.32bit.stderr @@ -42,60 +42,47 @@ LL | const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; 00 00 00 00 │ .... } -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/ub-ref-ptr.rs:31:1 | LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:35:39 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:34:39 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ---------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:35:38 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:34:38 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ---------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:41:86 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:38:86 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ------------------------------------------ ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:41:85 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:38:85 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ------------------------------------------ ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = 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 + | ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:47:1 + --> $DIR/ub-ref-ptr.rs:42:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (address 0x539 is unallocated) @@ -106,7 +93,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:50:1 + --> $DIR/ub-ref-ptr.rs:45:1 | LL | const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (address 0x539 is unallocated) @@ -116,19 +103,14 @@ LL | const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; 39 05 00 00 │ 9... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:53:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:48:41 | LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered uninitialized raw pointer - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 4, align: 4) { - __ __ __ __ │ ░░░░ - } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:56:1 + --> $DIR/ub-ref-ptr.rs:52:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer @@ -138,19 +120,14 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:58:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:54:38 | LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered uninitialized bytes, but expected a proper pointer or integer value - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 4, align: 4) { - __ __ __ __ │ ░░░░ - } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:60:1 + --> $DIR/ub-ref-ptr.rs:57:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer @@ -161,7 +138,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:62:1 + --> $DIR/ub-ref-ptr.rs:59:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered alloc41, but expected a function pointer @@ -174,64 +151,3 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; error: aborting due to 16 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/ub-ref-ptr.rs:31:1 - | -LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:35:39 - | -LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ---------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:35:38 - | -LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ---------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:41:86 - | -LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ------------------------------------------ ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:41:85 - | -LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ------------------------------------------ ^^^^^^^^^^^^^^^^^^^^^ 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 - diff --git a/src/test/ui/consts/const-eval/ub-ref-ptr.64bit.stderr b/src/test/ui/consts/const-eval/ub-ref-ptr.64bit.stderr index eeec2dc4b..5ffb710d4 100644 --- a/src/test/ui/consts/const-eval/ub-ref-ptr.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-ref-ptr.64bit.stderr @@ -42,60 +42,47 @@ LL | const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; 00 00 00 00 00 00 00 00 │ ........ } -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/ub-ref-ptr.rs:31:1 | LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:35:39 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:34:39 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ---------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:35:38 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:34:38 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ---------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:41:86 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:38:86 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ------------------------------------------ ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:41:85 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:38:85 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ------------------------------------------ ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = 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 + | ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:47:1 + --> $DIR/ub-ref-ptr.rs:42:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (address 0x539 is unallocated) @@ -106,7 +93,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:50:1 + --> $DIR/ub-ref-ptr.rs:45:1 | LL | const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (address 0x539 is unallocated) @@ -116,19 +103,14 @@ LL | const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; 39 05 00 00 00 00 00 00 │ 9....... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:53:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:48:41 | LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered uninitialized raw pointer - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 8, align: 8) { - __ __ __ __ __ __ __ __ │ ░░░░░░░░ - } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:56:1 + --> $DIR/ub-ref-ptr.rs:52:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer @@ -138,19 +120,14 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:58:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:54:38 | LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered uninitialized bytes, but expected a proper pointer or integer value - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 8, align: 8) { - __ __ __ __ __ __ __ __ │ ░░░░░░░░ - } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:60:1 + --> $DIR/ub-ref-ptr.rs:57:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer @@ -161,7 +138,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:62:1 + --> $DIR/ub-ref-ptr.rs:59:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered alloc41, but expected a function pointer @@ -174,64 +151,3 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; error: aborting due to 16 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/ub-ref-ptr.rs:31:1 - | -LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:35:39 - | -LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ---------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:35:38 - | -LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ---------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:41:86 - | -LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ------------------------------------------ ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:41:85 - | -LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ------------------------------------------ ^^^^^^^^^^^^^^^^^^^^^ 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 - diff --git a/src/test/ui/consts/const-eval/ub-ref-ptr.rs b/src/test/ui/consts/const-eval/ub-ref-ptr.rs index d0216f746..92049d4c1 100644 --- a/src/test/ui/consts/const-eval/ub-ref-ptr.rs +++ b/src/test/ui/consts/const-eval/ub-ref-ptr.rs @@ -29,20 +29,15 @@ const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; // but that would fail to compile; so we ended up breaking user code that would // have worked fine had we not promoted. const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out -//~| ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed +//~| ERROR evaluation of constant value failed const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out -//~| ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed +//~| ERROR evaluation of constant value failed const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; //~^ ERROR it is undefined behavior to use this value @@ -51,12 +46,14 @@ const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; //~^ ERROR it is undefined behavior to use this value const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR evaluation of constant value failed +//~| uninitialized const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; //~^ ERROR it is undefined behavior to use this value const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR evaluation of constant value failed +//~| uninitialized const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; //~^ ERROR it is undefined behavior to use this value const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; diff --git a/src/test/ui/consts/const-eval/ub-uninhabit.32bit.stderr b/src/test/ui/consts/const-eval/ub-uninhabit.32bit.stderr index 7f0feb130..7d3232257 100644 --- a/src/test/ui/consts/const-eval/ub-uninhabit.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-uninhabit.32bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:15:1 + --> $DIR/ub-uninhabit.rs:14:1 | LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type Bar @@ -8,7 +8,7 @@ LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; = note: the raw bytes of the constant (size: 0, align: 1) {} error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:18:1 + --> $DIR/ub-uninhabit.rs:17:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar @@ -19,7 +19,7 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:21:1 + --> $DIR/ub-uninhabit.rs:20:1 | LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a value of uninhabited type Bar diff --git a/src/test/ui/consts/const-eval/ub-uninhabit.64bit.stderr b/src/test/ui/consts/const-eval/ub-uninhabit.64bit.stderr index 4dcbbc2f5..2b7659f5d 100644 --- a/src/test/ui/consts/const-eval/ub-uninhabit.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-uninhabit.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:15:1 + --> $DIR/ub-uninhabit.rs:14:1 | LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type Bar @@ -8,7 +8,7 @@ LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; = note: the raw bytes of the constant (size: 0, align: 1) {} error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:18:1 + --> $DIR/ub-uninhabit.rs:17:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar @@ -19,7 +19,7 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:21:1 + --> $DIR/ub-uninhabit.rs:20:1 | LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a value of uninhabited type Bar diff --git a/src/test/ui/consts/const-eval/ub-uninhabit.rs b/src/test/ui/consts/const-eval/ub-uninhabit.rs index 33fbd14c4..213f15b79 100644 --- a/src/test/ui/consts/const-eval/ub-uninhabit.rs +++ b/src/test/ui/consts/const-eval/ub-uninhabit.rs @@ -1,5 +1,4 @@ // stderr-per-bitwidth -#![allow(const_err)] // make sure we cannot allow away the errors tested here use std::mem; diff --git a/src/test/ui/consts/const-eval/ub-upvars.rs b/src/test/ui/consts/const-eval/ub-upvars.rs index 57dd7b9e5..ceac59870 100644 --- a/src/test/ui/consts/const-eval/ub-upvars.rs +++ b/src/test/ui/consts/const-eval/ub-upvars.rs @@ -1,5 +1,5 @@ // stderr-per-bitwidth -#![allow(const_err, invalid_value)] // make sure we cannot allow away the errors tested here +#![allow(invalid_value)] // make sure we cannot allow away the errors tested here use std::mem; diff --git a/src/test/ui/consts/const-eval/ub-wide-ptr.32bit.stderr b/src/test/ui/consts/const-eval/ub-wide-ptr.32bit.stderr index c4f0e3ab4..c8b46608d 100644 --- a/src/test/ui/consts/const-eval/ub-wide-ptr.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-wide-ptr.32bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:37:1 + --> $DIR/ub-wide-ptr.rs:36:1 | LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) @@ -10,7 +10,7 @@ LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:39:1 + --> $DIR/ub-wide-ptr.rs:38:1 | LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object @@ -20,31 +20,26 @@ LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, us ╾─allocN─╼ ff ff ff ff │ ╾──╼.... } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:42:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:41:1 | LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:46:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:44:1 | LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:49:1 + --> $DIR/ub-wide-ptr.rs:46:1 | LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object @@ -55,7 +50,7 @@ LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize: } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:53:1 + --> $DIR/ub-wide-ptr.rs:50:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized data in `str` @@ -66,7 +61,7 @@ LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit: } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:56:1 + --> $DIR/ub-wide-ptr.rs:53:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered uninitialized data in `str` @@ -76,19 +71,14 @@ LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUni ╾─allocN─╼ 01 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:63:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:60:1 | LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered uninitialized reference - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 8, align: 4) { - 2a 00 00 00 __ __ __ __ │ *...░░░░ - } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:69:1 + --> $DIR/ub-wide-ptr.rs:67:1 | LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) @@ -99,7 +89,7 @@ LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:72:1 + --> $DIR/ub-wide-ptr.rs:70:1 | LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object @@ -109,19 +99,17 @@ LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, is ╾─allocN─╼ ff ff ff 7f │ ╾──╼.... } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:75:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:73:1 | LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:79:1 + --> $DIR/ub-wide-ptr.rs:76:1 | LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) @@ -131,19 +119,17 @@ LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999us ╾─allocN─╼ e7 03 00 00 │ ╾──╼.... } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:82:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:79:1 | LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:87:1 + --> $DIR/ub-wide-ptr.rs:83:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered 0x03, but expected a boolean @@ -153,17 +139,14 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; ╾─allocN─╼ │ ╾──╼ } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:87:40 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:83:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; - | ------------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:95:1 + --> $DIR/ub-wide-ptr.rs:90:1 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered 0x03, but expected a boolean @@ -173,17 +156,14 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 ╾allocN─╼ │ ╾──╼ } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:95:42 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:90:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); - | -------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:100:1 + --> $DIR/ub-wide-ptr.rs:94:1 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..1[0]: encountered 0x03, but expected a boolean @@ -193,28 +173,20 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran ╾allocN─╼ │ ╾──╼ } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:100:42 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:94:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); - | -------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:109:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:102:1 | LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered uninitialized raw pointer - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 8, align: 4) { - 2a 00 00 00 __ __ __ __ │ *...░░░░ - } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:117:1 + --> $DIR/ub-wide-ptr.rs:111:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer @@ -225,7 +197,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W(( } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:121:1 + --> $DIR/ub-wide-ptr.rs:115:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer @@ -236,7 +208,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W(( } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:125:1 + --> $DIR/ub-wide-ptr.rs:119:1 | LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer @@ -247,25 +219,25 @@ LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u } error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:128:57 + --> $DIR/ub-wide-ptr.rs:122:57 | LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:131:57 + --> $DIR/ub-wide-ptr.rs:125:57 | LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:134:56 + --> $DIR/ub-wide-ptr.rs:128:56 | LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:137:1 + --> $DIR/ub-wide-ptr.rs:131:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer @@ -276,7 +248,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::trans } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:142:1 + --> $DIR/ub-wide-ptr.rs:136:1 | LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..: encountered 0x03, but expected a boolean @@ -286,26 +258,36 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, ╾allocN─╼ ╾allocN─╼ │ ╾──╼╾──╼ } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:147:62 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-wide-ptr.rs:141:1 | LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 8, align: 4) { + ╾allocN─╼ 00 00 00 00 │ ╾──╼.... + } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:150:65 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-wide-ptr.rs:143:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered allocN, but expected a vtable pointer + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 8, align: 4) { + ╾allocN─╼ ╾allocN─╼ │ ╾──╼╾──╼ + } error[E0080]: could not evaluate static initializer - --> $DIR/ub-wide-ptr.rs:157:5 + --> $DIR/ub-wide-ptr.rs:149:5 | LL | mem::transmute::<_, &dyn Trait>((&92u8, 0usize)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) error[E0080]: could not evaluate static initializer - --> $DIR/ub-wide-ptr.rs:161:5 + --> $DIR/ub-wide-ptr.rs:153:5 | LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable @@ -313,88 +295,3 @@ LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64)) error: aborting due to 32 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/ub-wide-ptr.rs:42:1 - | -LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:46:1 - | -LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:75:1 - | -LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:82:1 - | -LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:87:40 - | -LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; - | ------------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:95:42 - | -LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); - | -------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:100:42 - | -LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); - | -------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 - diff --git a/src/test/ui/consts/const-eval/ub-wide-ptr.64bit.stderr b/src/test/ui/consts/const-eval/ub-wide-ptr.64bit.stderr index d6c612bb4..70574d2dc 100644 --- a/src/test/ui/consts/const-eval/ub-wide-ptr.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-wide-ptr.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:37:1 + --> $DIR/ub-wide-ptr.rs:36:1 | LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) @@ -10,7 +10,7 @@ LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:39:1 + --> $DIR/ub-wide-ptr.rs:38:1 | LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object @@ -20,31 +20,26 @@ LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, us ╾───────allocN───────╼ ff ff ff ff ff ff ff ff │ ╾──────╼........ } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:42:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:41:1 | LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:46:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:44:1 | LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:49:1 + --> $DIR/ub-wide-ptr.rs:46:1 | LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object @@ -55,7 +50,7 @@ LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize: } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:53:1 + --> $DIR/ub-wide-ptr.rs:50:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized data in `str` @@ -66,7 +61,7 @@ LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit: } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:56:1 + --> $DIR/ub-wide-ptr.rs:53:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered uninitialized data in `str` @@ -76,19 +71,14 @@ LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUni ╾───────allocN───────╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:63:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:60:1 | LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered uninitialized reference - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 16, align: 8) { - __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░ - } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:69:1 + --> $DIR/ub-wide-ptr.rs:67:1 | LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) @@ -99,7 +89,7 @@ LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:72:1 + --> $DIR/ub-wide-ptr.rs:70:1 | LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object @@ -109,19 +99,17 @@ LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, is ╾───────allocN───────╼ ff ff ff ff ff ff ff 7f │ ╾──────╼........ } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:75:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:73:1 | LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:79:1 + --> $DIR/ub-wide-ptr.rs:76:1 | LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) @@ -131,19 +119,17 @@ LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999us ╾───────allocN───────╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........ } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:82:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:79:1 | LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:87:1 + --> $DIR/ub-wide-ptr.rs:83:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered 0x03, but expected a boolean @@ -153,17 +139,14 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; ╾───────allocN───────╼ │ ╾──────╼ } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:87:40 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:83:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; - | ------------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:95:1 + --> $DIR/ub-wide-ptr.rs:90:1 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered 0x03, but expected a boolean @@ -173,17 +156,14 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 ╾──────allocN───────╼ │ ╾──────╼ } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:95:42 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:90:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); - | -------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:100:1 + --> $DIR/ub-wide-ptr.rs:94:1 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..1[0]: encountered 0x03, but expected a boolean @@ -193,28 +173,20 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran ╾──────allocN───────╼ │ ╾──────╼ } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:100:42 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:94:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); - | -------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:109:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:102:1 | LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered uninitialized raw pointer - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 16, align: 8) { - __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░ - } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:117:1 + --> $DIR/ub-wide-ptr.rs:111:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer @@ -225,7 +197,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W(( } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:121:1 + --> $DIR/ub-wide-ptr.rs:115:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer @@ -236,7 +208,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W(( } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:125:1 + --> $DIR/ub-wide-ptr.rs:119:1 | LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer @@ -247,25 +219,25 @@ LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u } error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:128:57 + --> $DIR/ub-wide-ptr.rs:122:57 | LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:131:57 + --> $DIR/ub-wide-ptr.rs:125:57 | LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:134:56 + --> $DIR/ub-wide-ptr.rs:128:56 | LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:137:1 + --> $DIR/ub-wide-ptr.rs:131:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer @@ -276,7 +248,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::trans } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:142:1 + --> $DIR/ub-wide-ptr.rs:136:1 | LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..: encountered 0x03, but expected a boolean @@ -286,26 +258,36 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, ╾──────allocN───────╼ ╾──────allocN───────╼ │ ╾──────╼╾──────╼ } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:147:62 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-wide-ptr.rs:141:1 | LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 16, align: 8) { + ╾──────allocN───────╼ 00 00 00 00 00 00 00 00 │ ╾──────╼........ + } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:150:65 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-wide-ptr.rs:143:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered allocN, but expected a vtable pointer + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 16, align: 8) { + ╾──────allocN───────╼ ╾──────allocN───────╼ │ ╾──────╼╾──────╼ + } error[E0080]: could not evaluate static initializer - --> $DIR/ub-wide-ptr.rs:157:5 + --> $DIR/ub-wide-ptr.rs:149:5 | LL | mem::transmute::<_, &dyn Trait>((&92u8, 0usize)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) error[E0080]: could not evaluate static initializer - --> $DIR/ub-wide-ptr.rs:161:5 + --> $DIR/ub-wide-ptr.rs:153:5 | LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable @@ -313,88 +295,3 @@ LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64)) error: aborting due to 32 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/ub-wide-ptr.rs:42:1 - | -LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:46:1 - | -LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:75:1 - | -LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:82:1 - | -LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:87:40 - | -LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; - | ------------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:95:42 - | -LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); - | -------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:100:42 - | -LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); - | -------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 - diff --git a/src/test/ui/consts/const-eval/ub-wide-ptr.rs b/src/test/ui/consts/const-eval/ub-wide-ptr.rs index a0377ab1e..65f6f0235 100644 --- a/src/test/ui/consts/const-eval/ub-wide-ptr.rs +++ b/src/test/ui/consts/const-eval/ub-wide-ptr.rs @@ -9,8 +9,7 @@ use std::mem; // normalize-stderr-test "size \d+" -> "size N" /// A newtype wrapper to prevent MIR generation from inserting reborrows that would affect the error -/// message. Use this whenever the message is "any use of this value will cause an error" instead of -/// "it is undefined behavior to use this value". +/// message. #[repr(transparent)] struct W(T); @@ -40,12 +39,10 @@ const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize:: //~^ ERROR it is undefined behavior to use this value // bad str const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed // bad str in user-defined unsized type const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; //~^ ERROR it is undefined behavior to use this value @@ -61,7 +58,8 @@ const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: const SLICE_VALID: &[u8] = unsafe { mem::transmute((&42u8, 1usize)) }; // bad slice: length uninit const SLICE_LENGTH_UNINIT: &[u8] = unsafe { -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR evaluation of constant value failed +//~| uninitialized let uninit_len = MaybeUninit:: { uninit: () }; mem::transmute((42, uninit_len)) }; @@ -73,41 +71,37 @@ const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize:: //~^ ERROR it is undefined behavior to use this value // bad slice: length not an int const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed // bad slice box: length too big const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; //~^ ERROR it is undefined behavior to use this value // bad slice box: length not an int const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed // bad data *inside* the slice const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; //~^ ERROR it is undefined behavior to use this value -//~| ERROR any use of this value will cause an error -//~| WARNING this was previously accepted +//~| ERROR evaluation of constant value failed // good MySliceBool const MYSLICE_GOOD: &MySliceBool = &MySlice(true, [false]); // bad: sized field is not okay const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); //~^ ERROR it is undefined behavior to use this value -//~| ERROR any use of this value will cause an error -//~| WARNING this was previously accepted +//~| ERROR evaluation of constant value failed // bad: unsized part is not okay const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); //~^ ERROR it is undefined behavior to use this value -//~| ERROR any use of this value will cause an error -//~| WARNING this was previously accepted +//~| ERROR evaluation of constant value failed // # raw slice const RAW_SLICE_VALID: *const [u8] = unsafe { mem::transmute((&42u8, 1usize)) }; // ok const RAW_SLICE_TOO_LONG: *const [u8] = unsafe { mem::transmute((&42u8, 999usize)) }; // ok because raw const RAW_SLICE_MUCH_TOO_LONG: *const [u8] = unsafe { mem::transmute((&42u8, usize::MAX)) }; // ok because raw const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR evaluation of constant value failed +//~| uninitialized let uninit_len = MaybeUninit:: { uninit: () }; mem::transmute((42, uninit_len)) }; @@ -145,11 +139,9 @@ const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool // # raw trait object const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; -//~^ ERROR evaluation of constant value failed -//~| null pointer +//~^ ERROR it is undefined behavior to use this value const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; -//~^ ERROR evaluation of constant value failed -//~| does not point to a vtable +//~^ ERROR it is undefined behavior to use this value const RAW_TRAIT_OBJ_CONTENT_INVALID: *const dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) } as *const dyn Trait; // ok because raw // Const eval fails for these, so they need to be statics to error. diff --git a/src/test/ui/consts/const-eval/union-const-eval-field.rs b/src/test/ui/consts/const-eval/union-const-eval-field.rs index a1e48cac4..d88bf2a84 100644 --- a/src/test/ui/consts/const-eval/union-const-eval-field.rs +++ b/src/test/ui/consts/const-eval/union-const-eval-field.rs @@ -26,7 +26,8 @@ const fn read_field2() -> Field2 { const fn read_field3() -> Field3 { const FIELD3: Field3 = unsafe { UNION.field3 }; - //~^ ERROR it is undefined behavior to use this value + //~^ ERROR evaluation of constant value failed + //~| uninitialized FIELD3 //~^ ERROR erroneous constant used [E0080] } diff --git a/src/test/ui/consts/const-eval/union-const-eval-field.stderr b/src/test/ui/consts/const-eval/union-const-eval-field.stderr index c512e6825..00964489e 100644 --- a/src/test/ui/consts/const-eval/union-const-eval-field.stderr +++ b/src/test/ui/consts/const-eval/union-const-eval-field.stderr @@ -1,16 +1,11 @@ -error[E0080]: it is undefined behavior to use this value - --> $DIR/union-const-eval-field.rs:28:5 +error[E0080]: evaluation of constant value failed + --> $DIR/union-const-eval-field.rs:28:37 | LL | const FIELD3: Field3 = unsafe { UNION.field3 }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered uninitialized bytes, but expected initialized bytes - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 8, align: 8) { - __ __ __ __ __ __ __ __ │ ░░░░░░░░ - } + | ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: erroneous constant used - --> $DIR/union-const-eval-field.rs:30:5 + --> $DIR/union-const-eval-field.rs:31:5 | LL | FIELD3 | ^^^^^^ referenced constant has errors diff --git a/src/test/ui/consts/const-eval/union-ice.rs b/src/test/ui/consts/const-eval/union-ice.rs index 4189619b2..dd970a355 100644 --- a/src/test/ui/consts/const-eval/union-ice.rs +++ b/src/test/ui/consts/const-eval/union-ice.rs @@ -11,11 +11,15 @@ union DummyUnion { const UNION: DummyUnion = DummyUnion { field1: 1065353216 }; -const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR it is undefined behavior to use this value +const FIELD3: Field3 = unsafe { UNION.field3 }; +//~^ ERROR evaluation of constant value failed +//~| uninitialized -const FIELD_PATH: Struct = Struct { //~ ERROR it is undefined behavior to use this value +const FIELD_PATH: Struct = Struct { a: 42, b: unsafe { UNION.field3 }, + //~^ ERROR evaluation of constant value failed + //~| uninitialized }; struct Struct { @@ -23,10 +27,12 @@ struct Struct { b: Field3, } -const FIELD_PATH2: Struct2 = Struct2 { //~ ERROR it is undefined behavior to use this value +const FIELD_PATH2: Struct2 = Struct2 { b: [ 21, unsafe { UNION.field3 }, + //~^ ERROR evaluation of constant value failed + //~| uninitialized 23, 24, ], diff --git a/src/test/ui/consts/const-eval/union-ice.stderr b/src/test/ui/consts/const-eval/union-ice.stderr index 21a545509..bd39a0551 100644 --- a/src/test/ui/consts/const-eval/union-ice.stderr +++ b/src/test/ui/consts/const-eval/union-ice.stderr @@ -1,37 +1,20 @@ -error[E0080]: it is undefined behavior to use this value - --> $DIR/union-ice.rs:14:1 +error[E0080]: evaluation of constant value failed + --> $DIR/union-ice.rs:14:33 | LL | const FIELD3: Field3 = unsafe { UNION.field3 }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered uninitialized bytes, but expected initialized bytes - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 8, align: 8) { - __ __ __ __ __ __ __ __ │ ░░░░░░░░ - } + | ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory -error[E0080]: it is undefined behavior to use this value - --> $DIR/union-ice.rs:16:1 - | -LL | const FIELD_PATH: Struct = Struct { - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .b: encountered uninitialized bytes, but expected initialized bytes +error[E0080]: evaluation of constant value failed + --> $DIR/union-ice.rs:20:17 | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 16, align: 8) { - __ __ __ __ __ __ __ __ 2a __ __ __ __ __ __ __ │ ░░░░░░░░*░░░░░░░ - } +LL | b: unsafe { UNION.field3 }, + | ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory -error[E0080]: it is undefined behavior to use this value - --> $DIR/union-ice.rs:26:1 - | -LL | const FIELD_PATH2: Struct2 = Struct2 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .b[1]: encountered uninitialized bytes +error[E0080]: evaluation of constant value failed + --> $DIR/union-ice.rs:33:18 | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 40, align: 8) { - 0x00 │ 15 00 00 00 00 00 00 00 __ __ __ __ __ __ __ __ │ ........░░░░░░░░ - 0x10 │ 17 00 00 00 00 00 00 00 18 00 00 00 00 00 00 00 │ ................ - 0x20 │ 2a __ __ __ __ __ __ __ │ *░░░░░░░ - } +LL | unsafe { UNION.field3 }, + | ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error: aborting due to 3 previous errors diff --git a/src/test/ui/consts/const-eval/union-ub.32bit.stderr b/src/test/ui/consts/const-eval/union-ub.32bit.stderr index baf682596..e5c8f88be 100644 --- a/src/test/ui/consts/const-eval/union-ub.32bit.stderr +++ b/src/test/ui/consts/const-eval/union-ub.32bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/union-ub.rs:33:1 + --> $DIR/union-ub.rs:32:1 | LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x2a, but expected a boolean @@ -9,16 +9,11 @@ LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; 2a │ * } -error[E0080]: it is undefined behavior to use this value - --> $DIR/union-ub.rs:35:1 +error[E0080]: evaluation of constant value failed + --> $DIR/union-ub.rs:34:36 | LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool}; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered uninitialized bytes, but expected a boolean - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 1, align: 1) { - __ │ ░ - } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/const-eval/union-ub.64bit.stderr b/src/test/ui/consts/const-eval/union-ub.64bit.stderr index baf682596..e5c8f88be 100644 --- a/src/test/ui/consts/const-eval/union-ub.64bit.stderr +++ b/src/test/ui/consts/const-eval/union-ub.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/union-ub.rs:33:1 + --> $DIR/union-ub.rs:32:1 | LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x2a, but expected a boolean @@ -9,16 +9,11 @@ LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; 2a │ * } -error[E0080]: it is undefined behavior to use this value - --> $DIR/union-ub.rs:35:1 +error[E0080]: evaluation of constant value failed + --> $DIR/union-ub.rs:34:36 | LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool}; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered uninitialized bytes, but expected a boolean - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 1, align: 1) { - __ │ ░ - } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/const-eval/union-ub.rs b/src/test/ui/consts/const-eval/union-ub.rs index c1bfe69a7..043870c9c 100644 --- a/src/test/ui/consts/const-eval/union-ub.rs +++ b/src/test/ui/consts/const-eval/union-ub.rs @@ -1,5 +1,4 @@ // stderr-per-bitwidth -#![allow(const_err)] // make sure we cannot allow away the errors tested here #[repr(C)] union DummyUnion { @@ -33,7 +32,8 @@ union Bar { const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; //~^ ERROR it is undefined behavior to use this value const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool}; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR evaluation of constant value failed +//~| uninitialized // The value is not valid for any union variant, but that's fine // unions are just a convenient way to transmute bits around diff --git a/src/test/ui/consts/const-eval/union_promotion.rs b/src/test/ui/consts/const-eval/union_promotion.rs index 7167f88a1..18894c45f 100644 --- a/src/test/ui/consts/const-eval/union_promotion.rs +++ b/src/test/ui/consts/const-eval/union_promotion.rs @@ -1,5 +1,3 @@ -#![allow(const_err)] - #[repr(C)] union Foo { a: &'static u32, diff --git a/src/test/ui/consts/const-eval/union_promotion.stderr b/src/test/ui/consts/const-eval/union_promotion.stderr index ed186e3eb..70808c520 100644 --- a/src/test/ui/consts/const-eval/union_promotion.stderr +++ b/src/test/ui/consts/const-eval/union_promotion.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/union_promotion.rs:10:29 + --> $DIR/union_promotion.rs:8:29 | LL | let x: &'static bool = &unsafe { | ____________-------------____^ diff --git a/src/test/ui/consts/const-eval/unused-broken-const.rs b/src/test/ui/consts/const-eval/unused-broken-const.rs index 3b4523681..0d2776bc2 100644 --- a/src/test/ui/consts/const-eval/unused-broken-const.rs +++ b/src/test/ui/consts/const-eval/unused-broken-const.rs @@ -3,7 +3,6 @@ // compile-flags: --emit=dep-info,metadata const FOO: i32 = [][0]; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed fn main() {} diff --git a/src/test/ui/consts/const-eval/unused-broken-const.stderr b/src/test/ui/consts/const-eval/unused-broken-const.stderr index df5bd524f..fbb10feb7 100644 --- a/src/test/ui/consts/const-eval/unused-broken-const.stderr +++ b/src/test/ui/consts/const-eval/unused-broken-const.stderr @@ -1,23 +1,9 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/unused-broken-const.rs:5:18 | LL | const FOO: i32 = [][0]; - | -------------- ^^^^^ index out of bounds: the length is 0 but the index is 0 - | - = 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 + | ^^^^^ index out of bounds: the length is 0 but the index is 0 error: aborting due to previous error -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/unused-broken-const.rs:5:18 - | -LL | const FOO: i32 = [][0]; - | -------------- ^^^^^ index out of bounds: the length is 0 but the index is 0 - | - = 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 - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/valid-const.rs b/src/test/ui/consts/const-eval/valid-const.rs index 9e4707182..5f47d1c4f 100644 --- a/src/test/ui/consts/const-eval/valid-const.rs +++ b/src/test/ui/consts/const-eval/valid-const.rs @@ -1,7 +1,6 @@ // check-pass // Some constants that *are* valid -#![deny(const_err)] use std::mem; use std::ptr::NonNull; diff --git a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr index bdaeb4a0f..63639729a 100644 --- a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr +++ b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr @@ -7,8 +7,8 @@ LL | unsafe { std::mem::transmute(()) } | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: `#[warn(invalid_value)]` on by default = note: the `!` type has no valid value + = note: `#[warn(invalid_value)]` on by default error[E0080]: evaluation of constant value failed --> $DIR/validate_uninhabited_zsts.rs:4:14 @@ -20,10 +20,10 @@ LL | unsafe { std::mem::transmute(()) } | inside `foo` at $DIR/validate_uninhabited_zsts.rs:4:14 ... LL | const FOO: [empty::Empty; 3] = [foo(); 3]; - | ----- inside `FOO` at $DIR/validate_uninhabited_zsts.rs:20:33 + | ----- inside `FOO` at $DIR/validate_uninhabited_zsts.rs:19:33 error[E0080]: it is undefined behavior to use this value - --> $DIR/validate_uninhabited_zsts.rs:23:1 + --> $DIR/validate_uninhabited_zsts.rs:21:1 | LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0].0: encountered a value of uninhabited type empty::Void @@ -32,7 +32,7 @@ LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; = note: the raw bytes of the constant (size: 0, align: 1) {} warning: the type `empty::Empty` does not permit zero-initialization - --> $DIR/validate_uninhabited_zsts.rs:23:42 + --> $DIR/validate_uninhabited_zsts.rs:21:42 | LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,11 +40,11 @@ LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | -note: enums with no variants have no valid value (in this struct field) - --> $DIR/validate_uninhabited_zsts.rs:16:22 +note: enums with no inhabited variants have no valid value + --> $DIR/validate_uninhabited_zsts.rs:13:5 | -LL | pub struct Empty(Void); - | ^^^^ +LL | enum Void {} + | ^^^^^^^^^ error: aborting due to 2 previous errors; 2 warnings emitted diff --git a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr index bdaeb4a0f..63639729a 100644 --- a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr +++ b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr @@ -7,8 +7,8 @@ LL | unsafe { std::mem::transmute(()) } | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: `#[warn(invalid_value)]` on by default = note: the `!` type has no valid value + = note: `#[warn(invalid_value)]` on by default error[E0080]: evaluation of constant value failed --> $DIR/validate_uninhabited_zsts.rs:4:14 @@ -20,10 +20,10 @@ LL | unsafe { std::mem::transmute(()) } | inside `foo` at $DIR/validate_uninhabited_zsts.rs:4:14 ... LL | const FOO: [empty::Empty; 3] = [foo(); 3]; - | ----- inside `FOO` at $DIR/validate_uninhabited_zsts.rs:20:33 + | ----- inside `FOO` at $DIR/validate_uninhabited_zsts.rs:19:33 error[E0080]: it is undefined behavior to use this value - --> $DIR/validate_uninhabited_zsts.rs:23:1 + --> $DIR/validate_uninhabited_zsts.rs:21:1 | LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0].0: encountered a value of uninhabited type empty::Void @@ -32,7 +32,7 @@ LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; = note: the raw bytes of the constant (size: 0, align: 1) {} warning: the type `empty::Empty` does not permit zero-initialization - --> $DIR/validate_uninhabited_zsts.rs:23:42 + --> $DIR/validate_uninhabited_zsts.rs:21:42 | LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,11 +40,11 @@ LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | -note: enums with no variants have no valid value (in this struct field) - --> $DIR/validate_uninhabited_zsts.rs:16:22 +note: enums with no inhabited variants have no valid value + --> $DIR/validate_uninhabited_zsts.rs:13:5 | -LL | pub struct Empty(Void); - | ^^^^ +LL | enum Void {} + | ^^^^^^^^^ error: aborting due to 2 previous errors; 2 warnings emitted diff --git a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs index 96f331275..c0b326215 100644 --- a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs +++ b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs @@ -16,10 +16,8 @@ pub mod empty { pub struct Empty(Void); } -#[warn(const_err)] const FOO: [empty::Empty; 3] = [foo(); 3]; -#[warn(const_err)] const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; //~^ ERROR it is undefined behavior to use this value //~| WARN the type `empty::Empty` does not permit zero-initialization diff --git a/src/test/ui/consts/const-external-macro-const-err.rs b/src/test/ui/consts/const-external-macro-const-err.rs index 440c42e32..5bd84330b 100644 --- a/src/test/ui/consts/const-external-macro-const-err.rs +++ b/src/test/ui/consts/const-external-macro-const-err.rs @@ -9,6 +9,5 @@ extern crate external_macro; use external_macro::static_assert; fn main() { - static_assert!(2 + 2 == 5); //~ ERROR - //~| WARN this was previously accepted by the compiler but is being phased out + static_assert!(2 + 2 == 5); //~ ERROR constant } diff --git a/src/test/ui/consts/const-external-macro-const-err.stderr b/src/test/ui/consts/const-external-macro-const-err.stderr index 205ee92df..81f6c09ff 100644 --- a/src/test/ui/consts/const-external-macro-const-err.stderr +++ b/src/test/ui/consts/const-external-macro-const-err.stderr @@ -1,25 +1,11 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/const-external-macro-const-err.rs:12:5 | LL | static_assert!(2 + 2 == 5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 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 = note: this error originates in the macro `static_assert` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-external-macro-const-err.rs:12:5 - | -LL | static_assert!(2 + 2 == 5); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 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 - = note: this error originates in the macro `static_assert` (in Nightly builds, run with -Z macro-backtrace for more info) - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-float-bits-reject-conv.rs b/src/test/ui/consts/const-float-bits-reject-conv.rs index b156ded4a..5bf54fdbb 100644 --- a/src/test/ui/consts/const-float-bits-reject-conv.rs +++ b/src/test/ui/consts/const-float-bits-reject-conv.rs @@ -28,22 +28,18 @@ fn f32() { const MASKED_NAN2: u32 = f32::NAN.to_bits() ^ 0x0055_5555; const_assert!(f32::from_bits(MASKED_NAN1).is_nan()); - //~^ ERROR any use of this value will cause an error - //~| WARNING this was previously accepted + //~^ ERROR evaluation of constant value failed const_assert!(f32::from_bits(MASKED_NAN1).is_nan()); - //~^ ERROR any use of this value will cause an error - //~| WARNING this was previously accepted + //~^ ERROR evaluation of constant value failed // LLVM does not guarantee that loads and stores of NaNs preserve their exact bit pattern. // In practice, this seems to only cause a problem on x86, since the most widely used calling // convention mandates that floating point values are returned on the x87 FPU stack. See #73328. if !cfg!(target_arch = "x86") { const_assert!(f32::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); - //~^ ERROR any use of this value will cause an error - //~| WARNING this was previously accepted + //~^ ERROR evaluation of constant value failed const_assert!(f32::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); - //~^ ERROR any use of this value will cause an error - //~| WARNING this was previously accepted + //~^ ERROR evaluation of constant value failed } } @@ -55,20 +51,16 @@ fn f64() { const MASKED_NAN2: u64 = f64::NAN.to_bits() ^ 0x0005_5555_5555_5555; const_assert!(f64::from_bits(MASKED_NAN1).is_nan()); - //~^ ERROR any use of this value will cause an error - //~| WARNING this was previously accepted + //~^ ERROR evaluation of constant value failed const_assert!(f64::from_bits(MASKED_NAN1).is_nan()); - //~^ ERROR any use of this value will cause an error - //~| WARNING this was previously accepted + //~^ ERROR evaluation of constant value failed // See comment above. if !cfg!(target_arch = "x86") { const_assert!(f64::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); - //~^ ERROR any use of this value will cause an error - //~| WARNING this was previously accepted + //~^ ERROR evaluation of constant value failed const_assert!(f64::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); - //~^ ERROR any use of this value will cause an error - //~| WARNING this was previously accepted + //~^ ERROR evaluation of constant value failed } } diff --git a/src/test/ui/consts/const-float-bits-reject-conv.stderr b/src/test/ui/consts/const-float-bits-reject-conv.stderr index d6e993a10..b3575f641 100644 --- a/src/test/ui/consts/const-float-bits-reject-conv.stderr +++ b/src/test/ui/consts/const-float-bits-reject-conv.stderr @@ -10,16 +10,6 @@ LL | panic!("const-eval error: cannot use f32::to_bits on a LL | unsafe { intrinsics::const_eval_select((self,), ct_f32_to_u32, rt_f32_to_u32) } | -------------------------------------------------------------------- inside `core::f32::::to_bits` at $SRC_DIR/core/src/num/f32.rs:LL:COL | - ::: $SRC_DIR/core/src/ops/function.rs:LL:COL - | -LL | extern "rust-call" fn call_once(self, args: Args) -> Self::Output; - | ------------------------------------------------------------------ inside ` u32 {core::f32::::to_bits::ct_f32_to_u32} as FnOnce<(f32,)>>::call_once - shim(fn(f32) -> u32 {core::f32::::to_bits::ct_f32_to_u32})` at $SRC_DIR/core/src/ops/function.rs:LL:COL - | - ::: $SRC_DIR/core/src/intrinsics.rs:LL:COL - | -LL | called_in_const.call_once(arg) - | ------------------------------ inside `const_eval_select::<(f32,), fn(f32) -> u32 {core::f32::::to_bits::ct_f32_to_u32}, [closure@core::f32::::to_bits::{closure#0}], u32>` at $SRC_DIR/core/src/intrinsics.rs:LL:COL - | ::: $DIR/const-float-bits-reject-conv.rs:27:30 | LL | const MASKED_NAN1: u32 = f32::NAN.to_bits() ^ 0x002A_AAAA; @@ -39,16 +29,6 @@ LL | panic!("const-eval error: cannot use f32::to_bits on a LL | unsafe { intrinsics::const_eval_select((self,), ct_f32_to_u32, rt_f32_to_u32) } | -------------------------------------------------------------------- inside `core::f32::::to_bits` at $SRC_DIR/core/src/num/f32.rs:LL:COL | - ::: $SRC_DIR/core/src/ops/function.rs:LL:COL - | -LL | extern "rust-call" fn call_once(self, args: Args) -> Self::Output; - | ------------------------------------------------------------------ inside ` u32 {core::f32::::to_bits::ct_f32_to_u32} as FnOnce<(f32,)>>::call_once - shim(fn(f32) -> u32 {core::f32::::to_bits::ct_f32_to_u32})` at $SRC_DIR/core/src/ops/function.rs:LL:COL - | - ::: $SRC_DIR/core/src/intrinsics.rs:LL:COL - | -LL | called_in_const.call_once(arg) - | ------------------------------ inside `const_eval_select::<(f32,), fn(f32) -> u32 {core::f32::::to_bits::ct_f32_to_u32}, [closure@core::f32::::to_bits::{closure#0}], u32>` at $SRC_DIR/core/src/intrinsics.rs:LL:COL - | ::: $DIR/const-float-bits-reject-conv.rs:28:30 | LL | const MASKED_NAN2: u32 = f32::NAN.to_bits() ^ 0x0055_5555; @@ -56,54 +36,29 @@ LL | const MASKED_NAN2: u32 = f32::NAN.to_bits() ^ 0x0055_5555; | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/const-float-bits-reject-conv.rs:30:34 | -LL | const _: () = assert!($a); - | ----------- -... LL | const_assert!(f32::from_bits(MASKED_NAN1).is_nan()); | ^^^^^^^^^^^ 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 -error: any use of this value will cause an error - --> $DIR/const-float-bits-reject-conv.rs:33:34 +error[E0080]: evaluation of constant value failed + --> $DIR/const-float-bits-reject-conv.rs:32:34 | -LL | const _: () = assert!($a); - | ----------- -... LL | const_assert!(f32::from_bits(MASKED_NAN1).is_nan()); | ^^^^^^^^^^^ referenced constant has errors - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-float-bits-reject-conv.rs:41:38 +error[E0080]: evaluation of constant value failed + --> $DIR/const-float-bits-reject-conv.rs:39:38 | -LL | const _: () = assert!($a == $b); - | ----------- -... LL | const_assert!(f32::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); | ^^^^^^^^^^^ referenced constant has errors - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-float-bits-reject-conv.rs:44:38 +error[E0080]: evaluation of constant value failed + --> $DIR/const-float-bits-reject-conv.rs:41:38 | -LL | const _: () = assert!($a == $b); - | ----------- -... LL | const_assert!(f32::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); | ^^^^^^^^^^^ referenced constant has errors - | - = 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 error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/num/f64.rs:LL:COL @@ -117,20 +72,10 @@ LL | panic!("const-eval error: cannot use f64::to_bits on a LL | unsafe { intrinsics::const_eval_select((self,), ct_f64_to_u64, rt_f64_to_u64) } | -------------------------------------------------------------------- inside `core::f64::::to_bits` at $SRC_DIR/core/src/num/f64.rs:LL:COL | - ::: $SRC_DIR/core/src/ops/function.rs:LL:COL - | -LL | extern "rust-call" fn call_once(self, args: Args) -> Self::Output; - | ------------------------------------------------------------------ inside ` u64 {core::f64::::to_bits::ct_f64_to_u64} as FnOnce<(f64,)>>::call_once - shim(fn(f64) -> u64 {core::f64::::to_bits::ct_f64_to_u64})` at $SRC_DIR/core/src/ops/function.rs:LL:COL - | - ::: $SRC_DIR/core/src/intrinsics.rs:LL:COL - | -LL | called_in_const.call_once(arg) - | ------------------------------ inside `const_eval_select::<(f64,), fn(f64) -> u64 {core::f64::::to_bits::ct_f64_to_u64}, [closure@core::f64::::to_bits::{closure#0}], u64>` at $SRC_DIR/core/src/intrinsics.rs:LL:COL - | - ::: $DIR/const-float-bits-reject-conv.rs:54:30 + ::: $DIR/const-float-bits-reject-conv.rs:50:30 | LL | const MASKED_NAN1: u64 = f64::NAN.to_bits() ^ 0x000A_AAAA_AAAA_AAAA; - | ------------------ inside `f64::MASKED_NAN1` at $DIR/const-float-bits-reject-conv.rs:54:30 + | ------------------ inside `f64::MASKED_NAN1` at $DIR/const-float-bits-reject-conv.rs:50:30 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -146,183 +91,37 @@ LL | panic!("const-eval error: cannot use f64::to_bits on a LL | unsafe { intrinsics::const_eval_select((self,), ct_f64_to_u64, rt_f64_to_u64) } | -------------------------------------------------------------------- inside `core::f64::::to_bits` at $SRC_DIR/core/src/num/f64.rs:LL:COL | - ::: $SRC_DIR/core/src/ops/function.rs:LL:COL - | -LL | extern "rust-call" fn call_once(self, args: Args) -> Self::Output; - | ------------------------------------------------------------------ inside ` u64 {core::f64::::to_bits::ct_f64_to_u64} as FnOnce<(f64,)>>::call_once - shim(fn(f64) -> u64 {core::f64::::to_bits::ct_f64_to_u64})` at $SRC_DIR/core/src/ops/function.rs:LL:COL - | - ::: $SRC_DIR/core/src/intrinsics.rs:LL:COL - | -LL | called_in_const.call_once(arg) - | ------------------------------ inside `const_eval_select::<(f64,), fn(f64) -> u64 {core::f64::::to_bits::ct_f64_to_u64}, [closure@core::f64::::to_bits::{closure#0}], u64>` at $SRC_DIR/core/src/intrinsics.rs:LL:COL - | - ::: $DIR/const-float-bits-reject-conv.rs:55:30 + ::: $DIR/const-float-bits-reject-conv.rs:51:30 | LL | const MASKED_NAN2: u64 = f64::NAN.to_bits() ^ 0x0005_5555_5555_5555; - | ------------------ inside `f64::MASKED_NAN2` at $DIR/const-float-bits-reject-conv.rs:55:30 + | ------------------ inside `f64::MASKED_NAN2` at $DIR/const-float-bits-reject-conv.rs:51:30 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error: any use of this value will cause an error - --> $DIR/const-float-bits-reject-conv.rs:57:34 +error[E0080]: evaluation of constant value failed + --> $DIR/const-float-bits-reject-conv.rs:53:34 | -LL | const _: () = assert!($a); - | ----------- -... LL | const_assert!(f64::from_bits(MASKED_NAN1).is_nan()); | ^^^^^^^^^^^ referenced constant has errors - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-float-bits-reject-conv.rs:60:34 +error[E0080]: evaluation of constant value failed + --> $DIR/const-float-bits-reject-conv.rs:55:34 | -LL | const _: () = assert!($a); - | ----------- -... LL | const_assert!(f64::from_bits(MASKED_NAN1).is_nan()); | ^^^^^^^^^^^ referenced constant has errors - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-float-bits-reject-conv.rs:66:38 +error[E0080]: evaluation of constant value failed + --> $DIR/const-float-bits-reject-conv.rs:60:38 | -LL | const _: () = assert!($a == $b); - | ----------- -... LL | const_assert!(f64::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); | ^^^^^^^^^^^ referenced constant has errors - | - = 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 -error: any use of this value will cause an error - --> $DIR/const-float-bits-reject-conv.rs:69:38 +error[E0080]: evaluation of constant value failed + --> $DIR/const-float-bits-reject-conv.rs:62:38 | -LL | const _: () = assert!($a == $b); - | ----------- -... LL | const_assert!(f64::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); | ^^^^^^^^^^^ referenced constant has errors - | - = 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 error: aborting due to 12 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/const-float-bits-reject-conv.rs:30:34 - | -LL | const _: () = assert!($a); - | ----------- -... -LL | const_assert!(f32::from_bits(MASKED_NAN1).is_nan()); - | ^^^^^^^^^^^ 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-float-bits-reject-conv.rs:33:34 - | -LL | const _: () = assert!($a); - | ----------- -... -LL | const_assert!(f32::from_bits(MASKED_NAN1).is_nan()); - | ^^^^^^^^^^^ 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-float-bits-reject-conv.rs:41:38 - | -LL | const _: () = assert!($a == $b); - | ----------- -... -LL | const_assert!(f32::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); - | ^^^^^^^^^^^ 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-float-bits-reject-conv.rs:44:38 - | -LL | const _: () = assert!($a == $b); - | ----------- -... -LL | const_assert!(f32::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); - | ^^^^^^^^^^^ 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-float-bits-reject-conv.rs:57:34 - | -LL | const _: () = assert!($a); - | ----------- -... -LL | const_assert!(f64::from_bits(MASKED_NAN1).is_nan()); - | ^^^^^^^^^^^ 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-float-bits-reject-conv.rs:60:34 - | -LL | const _: () = assert!($a); - | ----------- -... -LL | const_assert!(f64::from_bits(MASKED_NAN1).is_nan()); - | ^^^^^^^^^^^ 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-float-bits-reject-conv.rs:66:38 - | -LL | const _: () = assert!($a == $b); - | ----------- -... -LL | const_assert!(f64::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); - | ^^^^^^^^^^^ 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-float-bits-reject-conv.rs:69:38 - | -LL | const _: () = assert!($a == $b); - | ----------- -... -LL | const_assert!(f64::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); - | ^^^^^^^^^^^ 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 - diff --git a/src/test/ui/consts/const-fn-error.rs b/src/test/ui/consts/const-fn-error.rs index abe68c17a..50b7ce1f8 100644 --- a/src/test/ui/consts/const-fn-error.rs +++ b/src/test/ui/consts/const-fn-error.rs @@ -3,10 +3,10 @@ const X : usize = 2; const fn f(x: usize) -> usize { let mut sum = 0; for i in 0..x { - //~^ ERROR mutable references - //~| ERROR cannot convert - //~| ERROR cannot call non-const fn + //~^ ERROR cannot convert //~| ERROR `for` is not allowed in a `const fn` + //~| ERROR mutable references are not allowed in constant functions + //~| ERROR cannot call non-const fn sum += i; } sum diff --git a/src/test/ui/consts/const-fn-error.stderr b/src/test/ui/consts/const-fn-error.stderr index e36324f0b..02960b363 100644 --- a/src/test/ui/consts/const-fn-error.stderr +++ b/src/test/ui/consts/const-fn-error.stderr @@ -22,8 +22,8 @@ LL | for i in 0..x { note: impl defined here, but it is not `const` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL | -LL | impl const IntoIterator for I { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | impl const IntoIterator for I { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0658]: mutable references are not allowed in constant functions diff --git a/src/test/ui/consts/const-for.rs b/src/test/ui/consts/const-for.rs index 58bcb5f74..8db248535 100644 --- a/src/test/ui/consts/const-for.rs +++ b/src/test/ui/consts/const-for.rs @@ -3,8 +3,8 @@ const _: () = { for _ in 0..5 {} - //~^ error: cannot convert - //~| error: cannot call non-const fn + //~^ error: cannot call + //~| error: cannot convert }; fn main() {} diff --git a/src/test/ui/consts/const-for.stderr b/src/test/ui/consts/const-for.stderr index f2e1c8a49..11e4ae309 100644 --- a/src/test/ui/consts/const-for.stderr +++ b/src/test/ui/consts/const-for.stderr @@ -7,8 +7,8 @@ LL | for _ in 0..5 {} note: impl defined here, but it is not `const` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL | -LL | impl const IntoIterator for I { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | impl const IntoIterator for I { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn ` as Iterator>::next` in constants diff --git a/src/test/ui/consts/const-int-arithmetic-overflow.rs b/src/test/ui/consts/const-int-arithmetic-overflow.rs index 99bbeaafd..6446e9451 100644 --- a/src/test/ui/consts/const-int-arithmetic-overflow.rs +++ b/src/test/ui/consts/const-int-arithmetic-overflow.rs @@ -1,6 +1,5 @@ // run-pass // compile-flags: -O -#![allow(const_err)] // Make sure arithmetic unary/binary ops actually return the right result, even when overflowing. // We have to put them in `const fn` and turn on optimizations to avoid overflow checks. diff --git a/src/test/ui/consts/const-len-underflow-separate-spans.rs b/src/test/ui/consts/const-len-underflow-separate-spans.rs index 7c3d1f320..478761aef 100644 --- a/src/test/ui/consts/const-len-underflow-separate-spans.rs +++ b/src/test/ui/consts/const-len-underflow-separate-spans.rs @@ -5,8 +5,7 @@ const ONE: usize = 1; const TWO: usize = 2; const LEN: usize = ONE - TWO; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR constant fn main() { let a: [i8; LEN] = unimplemented!(); diff --git a/src/test/ui/consts/const-len-underflow-separate-spans.stderr b/src/test/ui/consts/const-len-underflow-separate-spans.stderr index d1bf4b92e..1416e695e 100644 --- a/src/test/ui/consts/const-len-underflow-separate-spans.stderr +++ b/src/test/ui/consts/const-len-underflow-separate-spans.stderr @@ -1,15 +1,11 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/const-len-underflow-separate-spans.rs:7:20 | LL | const LEN: usize = ONE - TWO; - | ---------------- ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, 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 + | ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow error[E0080]: evaluation of constant value failed - --> $DIR/const-len-underflow-separate-spans.rs:12:17 + --> $DIR/const-len-underflow-separate-spans.rs:11:17 | LL | let a: [i8; LEN] = unimplemented!(); | ^^^ referenced constant has errors @@ -17,14 +13,3 @@ LL | let a: [i8; LEN] = unimplemented!(); error: aborting due to 2 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/const-len-underflow-separate-spans.rs:7:20 - | -LL | const LEN: usize = ONE - TWO; - | ---------------- ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, 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 - diff --git a/src/test/ui/consts/const-negation.rs b/src/test/ui/consts/const-negation.rs index 26c3c0b83..18bcdfb01 100644 --- a/src/test/ui/consts/const-negation.rs +++ b/src/test/ui/consts/const-negation.rs @@ -1,8 +1,6 @@ // run-pass #![allow(overflowing_literals)] -#[deny(const_err)] - fn main() { #[cfg(target_pointer_width = "32")] const I: isize = -2147483648isize; diff --git a/src/test/ui/consts/const-points-to-static.32bit.stderr b/src/test/ui/consts/const-points-to-static.32bit.stderr index 97825dd0e..c7a435a1e 100644 --- a/src/test/ui/consts/const-points-to-static.32bit.stderr +++ b/src/test/ui/consts/const-points-to-static.32bit.stderr @@ -2,7 +2,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/const-points-to-static.rs:6:1 | LL | const TEST: &u8 = &MY_STATIC; - | ^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable + | ^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { diff --git a/src/test/ui/consts/const-points-to-static.64bit.stderr b/src/test/ui/consts/const-points-to-static.64bit.stderr index 0d4a5a8ce..4d5b8eac5 100644 --- a/src/test/ui/consts/const-points-to-static.64bit.stderr +++ b/src/test/ui/consts/const-points-to-static.64bit.stderr @@ -2,7 +2,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/const-points-to-static.rs:6:1 | LL | const TEST: &u8 = &MY_STATIC; - | ^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable + | ^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { diff --git a/src/test/ui/consts/const-prop-read-static-in-const.rs b/src/test/ui/consts/const-prop-read-static-in-const.rs index a65b707f0..214262059 100644 --- a/src/test/ui/consts/const-prop-read-static-in-const.rs +++ b/src/test/ui/consts/const-prop-read-static-in-const.rs @@ -2,8 +2,7 @@ #![allow(dead_code)] -const TEST: u8 = MY_STATIC; //~ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +const TEST: u8 = MY_STATIC; //~ ERROR constant static MY_STATIC: u8 = 4; diff --git a/src/test/ui/consts/const-prop-read-static-in-const.stderr b/src/test/ui/consts/const-prop-read-static-in-const.stderr index ea5ad24b0..793da6285 100644 --- a/src/test/ui/consts/const-prop-read-static-in-const.stderr +++ b/src/test/ui/consts/const-prop-read-static-in-const.stderr @@ -1,12 +1,8 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/const-prop-read-static-in-const.rs:5:18 | LL | const TEST: u8 = MY_STATIC; - | -------------- ^^^^^^^^^ constant accesses static - | - = 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 + | ^^^^^^^^^ constant accesses static warning: skipping const checks | @@ -18,14 +14,4 @@ LL | const TEST: u8 = MY_STATIC; error: aborting due to previous error; 1 warning emitted -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-prop-read-static-in-const.rs:5:18 - | -LL | const TEST: u8 = MY_STATIC; - | -------------- ^^^^^^^^^ constant accesses static - | - = 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 - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.rs b/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.rs index 665371777..4df3a793b 100644 --- a/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.rs +++ b/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.rs @@ -8,9 +8,7 @@ extern "C" { type Opaque; } -const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) }; //~ ERROR -//~| WARN this was previously accepted by the compiler but is being phased out -const _ALIGN: usize = unsafe { min_align_of_val(&4 as *const i32 as *const Opaque) }; //~ ERROR -//~| WARN this was previously accepted by the compiler but is being phased out +const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) }; //~ ERROR constant +const _ALIGN: usize = unsafe { min_align_of_val(&4 as *const i32 as *const Opaque) }; //~ ERROR constant fn main() {} diff --git a/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.stderr b/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.stderr index d19a89378..ad2de0f4d 100644 --- a/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.stderr +++ b/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.stderr @@ -1,43 +1,15 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/const-size_of_val-align_of_val-extern-type.rs:11:31 | LL | const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) }; - | ------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `extern type` does not have known layout - | - = 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `extern type` does not have known layout -error: any use of this value will cause an error - --> $DIR/const-size_of_val-align_of_val-extern-type.rs:13:32 +error[E0080]: evaluation of constant value failed + --> $DIR/const-size_of_val-align_of_val-extern-type.rs:12:32 | LL | const _ALIGN: usize = unsafe { min_align_of_val(&4 as *const i32 as *const Opaque) }; - | ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `extern type` does not have known layout - | - = 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `extern type` does not have known layout error: aborting due to 2 previous errors -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-size_of_val-align_of_val-extern-type.rs:11:31 - | -LL | const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) }; - | ------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `extern type` does not have known layout - | - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-size_of_val-align_of_val-extern-type.rs:13:32 - | -LL | const _ALIGN: usize = unsafe { min_align_of_val(&4 as *const i32 as *const Opaque) }; - | ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `extern type` does not have known layout - | - = 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 - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-slice-oob.rs b/src/test/ui/consts/const-slice-oob.rs index 35e5a4d22..429b97821 100644 --- a/src/test/ui/consts/const-slice-oob.rs +++ b/src/test/ui/consts/const-slice-oob.rs @@ -1,10 +1,7 @@ -#[deny(const_err)] - const FOO: &'static[u32] = &[1, 2, 3]; const BAR: u32 = FOO[5]; //~^ index out of bounds: the length is 3 but the index is 5 -//~| ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~| ERROR evaluation of constant value failed fn main() { let _ = BAR; diff --git a/src/test/ui/consts/const-slice-oob.stderr b/src/test/ui/consts/const-slice-oob.stderr index 27c21e7af..746883a79 100644 --- a/src/test/ui/consts/const-slice-oob.stderr +++ b/src/test/ui/consts/const-slice-oob.stderr @@ -1,23 +1,9 @@ -error: any use of this value will cause an error - --> $DIR/const-slice-oob.rs:4:18 +error[E0080]: evaluation of constant value failed + --> $DIR/const-slice-oob.rs:2:18 | LL | const BAR: u32 = FOO[5]; - | -------------- ^^^^^^ index out of bounds: the length is 3 but the index is 5 - | - = 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 + | ^^^^^^ index out of bounds: the length is 3 but the index is 5 error: aborting due to previous error -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-slice-oob.rs:4:18 - | -LL | const BAR: u32 = FOO[5]; - | -------------- ^^^^^^ index out of bounds: the length is 3 but the index is 5 - | - = 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 - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const_discriminant.rs b/src/test/ui/consts/const_discriminant.rs index f623c5101..79e68590e 100644 --- a/src/test/ui/consts/const_discriminant.rs +++ b/src/test/ui/consts/const_discriminant.rs @@ -1,6 +1,5 @@ // run-pass #![feature(const_discriminant)] -#![feature(bench_black_box)] #![allow(dead_code)] use std::mem::{discriminant, Discriminant}; diff --git a/src/test/ui/consts/const_in_pattern/custom-eq-branch-warn.stderr b/src/test/ui/consts/const_in_pattern/custom-eq-branch-warn.stderr index e51d6f916..223482722 100644 --- a/src/test/ui/consts/const_in_pattern/custom-eq-branch-warn.stderr +++ b/src/test/ui/consts/const_in_pattern/custom-eq-branch-warn.stderr @@ -4,9 +4,9 @@ warning: to use a constant of type `CustomEq` in a pattern, the constant's initi LL | BAR_BAZ => panic!(), | ^^^^^^^ | - = note: `#[warn(nontrivial_structural_match)]` 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 #73448 + = note: `#[warn(nontrivial_structural_match)]` on by default warning: 1 warning emitted diff --git a/src/test/ui/consts/const_in_pattern/incomplete-slice.rs b/src/test/ui/consts/const_in_pattern/incomplete-slice.rs new file mode 100644 index 000000000..e1ccda71d --- /dev/null +++ b/src/test/ui/consts/const_in_pattern/incomplete-slice.rs @@ -0,0 +1,15 @@ +#[derive(PartialEq)] +enum E { + A, +} + +const E_SL: &[E] = &[E::A]; + +fn main() { + match &[][..] { + //~^ ERROR non-exhaustive patterns: `&_` not covered [E0004] + E_SL => {} + //~^ WARN to use a constant of type `E` in a pattern, `E` must be annotated with `#[derive(PartialEq, Eq)]` + //~| WARN this was previously accepted by the compiler but is being phased out + } +} diff --git a/src/test/ui/consts/const_in_pattern/incomplete-slice.stderr b/src/test/ui/consts/const_in_pattern/incomplete-slice.stderr new file mode 100644 index 000000000..ddc576ced --- /dev/null +++ b/src/test/ui/consts/const_in_pattern/incomplete-slice.stderr @@ -0,0 +1,26 @@ +warning: to use a constant of type `E` in a pattern, `E` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/incomplete-slice.rs:11:9 + | +LL | E_SL => {} + | ^^^^ + | + = 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 #62411 + = note: `#[warn(indirect_structural_match)]` on by default + +error[E0004]: non-exhaustive patterns: `&_` not covered + --> $DIR/incomplete-slice.rs:9:11 + | +LL | match &[][..] { + | ^^^^^^^ pattern `&_` not covered + | + = note: the matched value is of type `&[E]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ E_SL => {} +LL + &_ => todo!() + | + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0004`. diff --git a/src/test/ui/consts/const_in_pattern/issue-44333.stderr b/src/test/ui/consts/const_in_pattern/issue-44333.stderr index 8302b09e5..731ef509c 100644 --- a/src/test/ui/consts/const_in_pattern/issue-44333.stderr +++ b/src/test/ui/consts/const_in_pattern/issue-44333.stderr @@ -4,13 +4,13 @@ warning: function pointers and unsized pointers in patterns behave unpredictably LL | FOO => println!("foo"), | ^^^ | + = 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 #62411 note: the lint level is defined here --> $DIR/issue-44333.rs:3:9 | LL | #![warn(pointer_structural_match)] | ^^^^^^^^^^^^^^^^^^^^^^^^ - = 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 #62411 warning: function pointers and unsized pointers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/issue-44333.rs:21:9 diff --git a/src/test/ui/consts/const_in_pattern/reject_non_structural.stderr b/src/test/ui/consts/const_in_pattern/reject_non_structural.stderr index 56405a55d..660198349 100644 --- a/src/test/ui/consts/const_in_pattern/reject_non_structural.stderr +++ b/src/test/ui/consts/const_in_pattern/reject_non_structural.stderr @@ -64,13 +64,13 @@ warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be a LL | match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), }; | ^^^^^^^ | + = 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 #62411 note: the lint level is defined here --> $DIR/reject_non_structural.rs:12:9 | LL | #![warn(indirect_structural_match)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ - = 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 #62411 error: aborting due to 10 previous errors; 1 warning emitted diff --git a/src/test/ui/consts/const_in_pattern/warn_corner_cases.stderr b/src/test/ui/consts/const_in_pattern/warn_corner_cases.stderr index a24c8d181..e957a43a1 100644 --- a/src/test/ui/consts/const_in_pattern/warn_corner_cases.stderr +++ b/src/test/ui/consts/const_in_pattern/warn_corner_cases.stderr @@ -4,9 +4,9 @@ warning: to use a constant of type `NoDerive` in a pattern, the constant's initi LL | match None { Some(_) => panic!("whoops"), INDEX => dbg!(INDEX), }; | ^^^^^ | - = note: `#[warn(nontrivial_structural_match)]` 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 #73448 + = note: `#[warn(nontrivial_structural_match)]` on by default warning: to use a constant of type `NoDerive` in a pattern, the constant's initializer must be trivial or `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` --> $DIR/warn_corner_cases.rs:32:47 diff --git a/src/test/ui/consts/const_limit/const_eval_limit_reached.rs b/src/test/ui/consts/const_limit/const_eval_limit_reached.rs index 773640b72..3ce038c1d 100644 --- a/src/test/ui/consts/const_limit/const_eval_limit_reached.rs +++ b/src/test/ui/consts/const_limit/const_eval_limit_reached.rs @@ -4,8 +4,7 @@ const X: usize = { let mut x = 0; while x != 1000 { - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed x += 1; } diff --git a/src/test/ui/consts/const_limit/const_eval_limit_reached.stderr b/src/test/ui/consts/const_limit/const_eval_limit_reached.stderr index e450f4aa3..850aebdfb 100644 --- a/src/test/ui/consts/const_limit/const_eval_limit_reached.stderr +++ b/src/test/ui/consts/const_limit/const_eval_limit_reached.stderr @@ -1,29 +1,9 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/const_eval_limit_reached.rs:6:11 | -LL | const X: usize = { - | -------------- -LL | let mut x = 0; LL | while x != 1000 { | ^^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`) - | - = 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 error: aborting due to previous error -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const_eval_limit_reached.rs:6:11 - | -LL | const X: usize = { - | -------------- -LL | let mut x = 0; -LL | while x != 1000 { - | ^^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`) - | - = 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 - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const_unsafe_unreachable_ub.stderr b/src/test/ui/consts/const_unsafe_unreachable_ub.stderr index ec6ce1f5d..f6de3699f 100644 --- a/src/test/ui/consts/const_unsafe_unreachable_ub.stderr +++ b/src/test/ui/consts/const_unsafe_unreachable_ub.stderr @@ -1,11 +1,11 @@ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/hint.rs:LL:COL | -LL | unsafe { intrinsics::unreachable() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | entering unreachable code - | inside `unreachable_unchecked` at $SRC_DIR/core/src/hint.rs:LL:COL +LL | intrinsics::unreachable() + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | entering unreachable code + | inside `unreachable_unchecked` at $SRC_DIR/core/src/hint.rs:LL:COL | ::: $DIR/const_unsafe_unreachable_ub.rs:6:18 | diff --git a/src/test/ui/consts/constifconst-call-in-const-position.rs b/src/test/ui/consts/constifconst-call-in-const-position.rs new file mode 100644 index 000000000..fcf01d5bc --- /dev/null +++ b/src/test/ui/consts/constifconst-call-in-const-position.rs @@ -0,0 +1,22 @@ +// known-bug: #102498 + +#![feature(const_trait_impl, generic_const_exprs)] + +#[const_trait] +pub trait Tr { + fn a() -> usize; +} + +impl Tr for () { + fn a() -> usize { + 1 + } +} + +const fn foo() -> [u8; T::a()] { + [0; T::a()] +} + +fn main() { + foo::<()>(); +} diff --git a/src/test/ui/consts/constifconst-call-in-const-position.stderr b/src/test/ui/consts/constifconst-call-in-const-position.stderr new file mode 100644 index 000000000..d4a445120 --- /dev/null +++ b/src/test/ui/consts/constifconst-call-in-const-position.stderr @@ -0,0 +1,18 @@ +warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/constifconst-call-in-const-position.rs:3:30 + | +LL | #![feature(const_trait_impl, generic_const_exprs)] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #76560 for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0080]: evaluation of `foo::<()>::{constant#0}` failed + --> $DIR/constifconst-call-in-const-position.rs:16:38 + | +LL | const fn foo() -> [u8; T::a()] { + | ^^^^^^ calling non-const function `<() as Tr>::a` + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/control-flow/drop-fail.precise.stderr b/src/test/ui/consts/control-flow/drop-fail.precise.stderr index 0b0b2443a..93b5f257e 100644 --- a/src/test/ui/consts/control-flow/drop-fail.precise.stderr +++ b/src/test/ui/consts/control-flow/drop-fail.precise.stderr @@ -1,14 +1,14 @@ -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Option>` cannot be evaluated at compile-time --> $DIR/drop-fail.rs:8:9 | LL | let x = Some(Vec::new()); - | ^ constants cannot evaluate destructors + | ^ the destructor for this type cannot be evaluated in constants -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Option>` cannot be evaluated at compile-time --> $DIR/drop-fail.rs:39:9 | LL | let mut tmp = None; - | ^^^^^^^ constants cannot evaluate destructors + | ^^^^^^^ the destructor for this type cannot be evaluated in constants error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/control-flow/drop-fail.rs b/src/test/ui/consts/control-flow/drop-fail.rs index efa5a11c9..41341f312 100644 --- a/src/test/ui/consts/control-flow/drop-fail.rs +++ b/src/test/ui/consts/control-flow/drop-fail.rs @@ -6,7 +6,7 @@ const _: Option> = { let y: Option> = None; let x = Some(Vec::new()); - //[stock,precise]~^ ERROR destructors cannot be evaluated at compile-time + //[stock,precise]~^ ERROR destructor of if true { x @@ -19,7 +19,7 @@ const _: Option> = { // existing analysis. const _: Vec = { let vec_tuple = (Vec::new(),); - //[stock]~^ ERROR destructors cannot be evaluated at compile-time + //[stock]~^ ERROR destructor of vec_tuple.0 }; @@ -27,7 +27,7 @@ const _: Vec = { // This applies to single-field enum variants as well. const _: Vec = { let x: Result<_, Vec> = Ok(Vec::new()); - //[stock]~^ ERROR destructors cannot be evaluated at compile-time + //[stock]~^ ERROR destructor of match x { Ok(x) | Err(x) => x, @@ -37,7 +37,7 @@ const _: Vec = { const _: Option> = { let mut some = Some(Vec::new()); let mut tmp = None; - //[stock,precise]~^ ERROR destructors cannot be evaluated at compile-time + //[stock,precise]~^ ERROR destructor of let mut i = 0; while i < 10 { diff --git a/src/test/ui/consts/control-flow/drop-fail.stock.stderr b/src/test/ui/consts/control-flow/drop-fail.stock.stderr index 72ca4fa08..2cc856802 100644 --- a/src/test/ui/consts/control-flow/drop-fail.stock.stderr +++ b/src/test/ui/consts/control-flow/drop-fail.stock.stderr @@ -1,35 +1,35 @@ -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Option>` cannot be evaluated at compile-time --> $DIR/drop-fail.rs:8:9 | LL | let x = Some(Vec::new()); - | ^ constants cannot evaluate destructors + | ^ the destructor for this type cannot be evaluated in constants ... LL | }; | - value is dropped here -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `(Vec,)` cannot be evaluated at compile-time --> $DIR/drop-fail.rs:21:9 | LL | let vec_tuple = (Vec::new(),); - | ^^^^^^^^^ constants cannot evaluate destructors + | ^^^^^^^^^ the destructor for this type cannot be evaluated in constants ... LL | }; | - value is dropped here -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Result, Vec>` cannot be evaluated at compile-time --> $DIR/drop-fail.rs:29:9 | LL | let x: Result<_, Vec> = Ok(Vec::new()); - | ^ constants cannot evaluate destructors + | ^ the destructor for this type cannot be evaluated in constants ... LL | }; | - value is dropped here -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Option>` cannot be evaluated at compile-time --> $DIR/drop-fail.rs:39:9 | LL | let mut tmp = None; - | ^^^^^^^ constants cannot evaluate destructors + | ^^^^^^^ the destructor for this type cannot be evaluated in constants ... LL | }; | - value is dropped here diff --git a/src/test/ui/consts/control-flow/issue-50577.stderr b/src/test/ui/consts/control-flow/issue-50577.stderr index b6e73f889..a931c89f4 100644 --- a/src/test/ui/consts/control-flow/issue-50577.stderr +++ b/src/test/ui/consts/control-flow/issue-50577.stderr @@ -2,7 +2,7 @@ error[E0317]: `if` may be missing an `else` clause --> $DIR/issue-50577.rs:3:16 | LL | Drop = assert_eq!(1, 1), - | ^^^^^^^^^^^^^^^^ expected `()`, found `isize` + | ^^^^^^^^^^^^^^^^ expected `isize`, found `()` | = note: `if` expressions without `else` evaluate to `()` = help: consider adding an `else` block that evaluates to the expected type diff --git a/src/test/ui/consts/dangling-alloc-id-ice.rs b/src/test/ui/consts/dangling-alloc-id-ice.rs index 95acacdb7..d591bfc73 100644 --- a/src/test/ui/consts/dangling-alloc-id-ice.rs +++ b/src/test/ui/consts/dangling-alloc-id-ice.rs @@ -1,5 +1,4 @@ // https://github.com/rust-lang/rust/issues/55223 -#![allow(const_err)] union Foo<'a> { y: &'a (), diff --git a/src/test/ui/consts/dangling-alloc-id-ice.stderr b/src/test/ui/consts/dangling-alloc-id-ice.stderr index 8410034c0..0a1cca4ca 100644 --- a/src/test/ui/consts/dangling-alloc-id-ice.stderr +++ b/src/test/ui/consts/dangling-alloc-id-ice.stderr @@ -1,5 +1,5 @@ error: encountered dangling pointer in final constant - --> $DIR/dangling-alloc-id-ice.rs:9:1 + --> $DIR/dangling-alloc-id-ice.rs:8:1 | LL | const FOO: &() = { | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/drop_box.rs b/src/test/ui/consts/drop_box.rs index 58a373a96..679974130 100644 --- a/src/test/ui/consts/drop_box.rs +++ b/src/test/ui/consts/drop_box.rs @@ -1,4 +1,4 @@ const fn f(_: Box) {} -//~^ ERROR destructors cannot be evaluated at compile-time +//~^ ERROR destructor of fn main() {} diff --git a/src/test/ui/consts/drop_box.stderr b/src/test/ui/consts/drop_box.stderr index b9d6581e8..62324939b 100644 --- a/src/test/ui/consts/drop_box.stderr +++ b/src/test/ui/consts/drop_box.stderr @@ -1,10 +1,10 @@ -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Box` cannot be evaluated at compile-time --> $DIR/drop_box.rs:1:15 | LL | const fn f(_: Box) {} | ^ - value is dropped here | | - | constant functions cannot evaluate destructors + | the destructor for this type cannot be evaluated in constant functions error: aborting due to previous error diff --git a/src/test/ui/consts/drop_zst.stderr b/src/test/ui/consts/drop_zst.stderr index d4be5aa56..37758a4cb 100644 --- a/src/test/ui/consts/drop_zst.stderr +++ b/src/test/ui/consts/drop_zst.stderr @@ -1,8 +1,8 @@ -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `S` cannot be evaluated at compile-time --> $DIR/drop_zst.rs:14:9 | LL | let s = S; - | ^ constant functions cannot evaluate destructors + | ^ the destructor for this type cannot be evaluated in constant functions error: aborting due to previous error diff --git a/src/test/ui/consts/extra-const-ub/detect-extra-ub.rs b/src/test/ui/consts/extra-const-ub/detect-extra-ub.rs new file mode 100644 index 000000000..159cdf257 --- /dev/null +++ b/src/test/ui/consts/extra-const-ub/detect-extra-ub.rs @@ -0,0 +1,42 @@ +// revisions: no_flag with_flag +// [no_flag] check-pass +// [with_flag] compile-flags: -Zextra-const-ub-checks +#![feature(const_ptr_read)] + +use std::mem::transmute; + +const INVALID_BOOL: () = unsafe { + let _x: bool = transmute(3u8); + //[with_flag]~^ ERROR: evaluation of constant value failed + //[with_flag]~| invalid value +}; + +const INVALID_PTR_IN_INT: () = unsafe { + let _x: usize = transmute(&3u8); + //[with_flag]~^ ERROR: evaluation of constant value failed +}; + +const INVALID_SLICE_TO_USIZE_TRANSMUTE: () = unsafe { + let x: &[u8] = &[0; 32]; + let _x: (usize, usize) = transmute(x); + //[with_flag]~^ ERROR: evaluation of constant value failed +}; + +const UNALIGNED_PTR: () = unsafe { + let _x: &u32 = transmute(&[0u8; 4]); + //[with_flag]~^ ERROR: evaluation of constant value failed + //[with_flag]~| invalid value +}; + +const UNALIGNED_READ: () = { + INNER; //[with_flag]~ERROR evaluation of constant value failed + // There is an error here but its span is in the standard library so we cannot match it... + // so we have this in a *nested* const, such that the *outer* const fails to use it. + const INNER: () = unsafe { + let x = &[0u8; 4]; + let ptr = x.as_ptr().cast::(); + ptr.read(); + }; +}; + +fn main() {} diff --git a/src/test/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr b/src/test/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr new file mode 100644 index 000000000..3e1195822 --- /dev/null +++ b/src/test/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr @@ -0,0 +1,58 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/detect-extra-ub.rs:9:20 + | +LL | let _x: bool = transmute(3u8); + | ^^^^^^^^^^^^^^ constructing invalid value: encountered 0x03, but expected a boolean + +error[E0080]: evaluation of constant value failed + --> $DIR/detect-extra-ub.rs:15:21 + | +LL | let _x: usize = transmute(&3u8); + | ^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported + +error[E0080]: evaluation of constant value failed + --> $DIR/detect-extra-ub.rs:21:30 + | +LL | let _x: (usize, usize) = transmute(x); + | ^^^^^^^^^^^^ unable to turn pointer into raw bytes + | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported + +error[E0080]: evaluation of constant value failed + --> $DIR/detect-extra-ub.rs:26:20 + | +LL | let _x: &u32 = transmute(&[0u8; 4]); + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 4 byte alignment but found 1) + +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | +LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | accessing memory with alignment 1, but alignment 4 is required + | inside `std::ptr::read::` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | + ::: $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | +LL | unsafe { read(self) } + | ---------- inside `ptr::const_ptr::::read` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | + ::: $DIR/detect-extra-ub.rs:38:9 + | +LL | ptr.read(); + | ---------- inside `INNER` at $DIR/detect-extra-ub.rs:38:9 + +error[E0080]: evaluation of constant value failed + --> $DIR/detect-extra-ub.rs:32:5 + | +LL | INNER; + | ^^^^^ referenced constant has errors + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/extra-const-ub/issue-100771.rs b/src/test/ui/consts/extra-const-ub/issue-100771.rs new file mode 100644 index 000000000..a32960328 --- /dev/null +++ b/src/test/ui/consts/extra-const-ub/issue-100771.rs @@ -0,0 +1,20 @@ +// check-pass +// compile-flags: -Zextra-const-ub-checks + +#[derive(PartialEq, Eq, Copy, Clone)] +#[repr(packed)] +struct Foo { + field: (i64, u32, u32, u32), +} + +const FOO: Foo = Foo { + field: (5, 6, 7, 8), +}; + +fn main() { + match FOO { + Foo { field: (5, 6, 7, 8) } => {}, + FOO => unreachable!(), + _ => unreachable!(), + } +} diff --git a/src/test/ui/consts/extra-const-ub/issue-101034.rs b/src/test/ui/consts/extra-const-ub/issue-101034.rs new file mode 100644 index 000000000..e0de705c4 --- /dev/null +++ b/src/test/ui/consts/extra-const-ub/issue-101034.rs @@ -0,0 +1,17 @@ +// check-pass +// compile-flags: -Zextra-const-ub-checks + +#[repr(packed)] +pub struct Foo { + bar: u8, + baa: [u32; 1], +} + +const FOOMP: Foo = Foo { + bar: 0, + baa: [69; 1], +}; + +fn main() { + let _val = FOOMP; +} diff --git a/src/test/ui/consts/invalid-union.32bit.stderr b/src/test/ui/consts/invalid-union.32bit.stderr index ae5f6b2ba..bad07989e 100644 --- a/src/test/ui/consts/invalid-union.32bit.stderr +++ b/src/test/ui/consts/invalid-union.32bit.stderr @@ -9,27 +9,12 @@ LL | fn main() { ╾─alloc7──╼ │ ╾──╼ } -error: erroneous constant used +error[E0080]: erroneous constant used --> $DIR/invalid-union.rs:42:25 | LL | let _: &'static _ = &C; | ^^ 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 error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. -Future incompatibility report: Future breakage diagnostic: -error: erroneous constant used - --> $DIR/invalid-union.rs:42:25 - | -LL | let _: &'static _ = &C; - | ^^ 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 - diff --git a/src/test/ui/consts/invalid-union.64bit.stderr b/src/test/ui/consts/invalid-union.64bit.stderr index d50e74a16..a209f0038 100644 --- a/src/test/ui/consts/invalid-union.64bit.stderr +++ b/src/test/ui/consts/invalid-union.64bit.stderr @@ -9,27 +9,12 @@ LL | fn main() { ╾───────alloc7────────╼ │ ╾──────╼ } -error: erroneous constant used +error[E0080]: erroneous constant used --> $DIR/invalid-union.rs:42:25 | LL | let _: &'static _ = &C; | ^^ 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 error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. -Future incompatibility report: Future breakage diagnostic: -error: erroneous constant used - --> $DIR/invalid-union.rs:42:25 - | -LL | let _: &'static _ = &C; - | ^^ 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 - diff --git a/src/test/ui/consts/invalid-union.rs b/src/test/ui/consts/invalid-union.rs index efeddf75c..435d26d6e 100644 --- a/src/test/ui/consts/invalid-union.rs +++ b/src/test/ui/consts/invalid-union.rs @@ -40,5 +40,4 @@ const C: S = { fn main() { //~ ERROR it is undefined behavior to use this value let _: &'static _ = &C; //~ ERROR erroneous constant used - //~^ WARN this was previously accepted } diff --git a/src/test/ui/consts/issue-102117.rs b/src/test/ui/consts/issue-102117.rs new file mode 100644 index 000000000..b77342c41 --- /dev/null +++ b/src/test/ui/consts/issue-102117.rs @@ -0,0 +1,30 @@ +#![feature(inline_const, const_type_id)] + +use std::alloc::Layout; +use std::any::TypeId; +use std::mem::transmute; +use std::ptr::drop_in_place; + +pub struct VTable { + layout: Layout, + type_id: TypeId, + drop_in_place: unsafe fn(*mut ()), +} + +impl VTable { + pub fn new() -> &'static Self { + const { + //~^ ERROR the parameter type `T` may not live long enough + //~| ERROR the parameter type `T` may not live long enough + &VTable { + layout: Layout::new::(), + type_id: TypeId::of::(), + drop_in_place: unsafe { + transmute::(drop_in_place::) + }, + } + } + } +} + +fn main() {} diff --git a/src/test/ui/consts/issue-102117.stderr b/src/test/ui/consts/issue-102117.stderr new file mode 100644 index 000000000..eb4b329bd --- /dev/null +++ b/src/test/ui/consts/issue-102117.stderr @@ -0,0 +1,37 @@ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/issue-102117.rs:16:9 + | +LL | / const { +LL | | +LL | | +LL | | &VTable { +... | +LL | | } +LL | | } + | |_________^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | pub fn new() -> &'static Self { + | +++++++++ + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/issue-102117.rs:16:9 + | +LL | / const { +LL | | +LL | | +LL | | &VTable { +... | +LL | | } +LL | | } + | |_________^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | pub fn new() -> &'static Self { + | +++++++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0310`. diff --git a/src/test/ui/consts/issue-104155.rs b/src/test/ui/consts/issue-104155.rs new file mode 100644 index 000000000..1cc8f81b0 --- /dev/null +++ b/src/test/ui/consts/issue-104155.rs @@ -0,0 +1,5 @@ +// check-pass +const _: () = core::mem::forget(Box::::default); +const _: () = core::mem::forget(|| Box::::default()); + +fn main() {} diff --git a/src/test/ui/consts/issue-17718-constants-not-static.rs b/src/test/ui/consts/issue-17718-constants-not-static.rs new file mode 100644 index 000000000..2e6aff161 --- /dev/null +++ b/src/test/ui/consts/issue-17718-constants-not-static.rs @@ -0,0 +1,9 @@ +fn id(x: T) -> T { x } + +const FOO: usize = 3; + +fn foo() -> &'static usize { &id(FOO) } +//~^ ERROR: cannot return reference to temporary value + +fn main() { +} diff --git a/src/test/ui/consts/issue-17718-constants-not-static.stderr b/src/test/ui/consts/issue-17718-constants-not-static.stderr new file mode 100644 index 000000000..8f3acae71 --- /dev/null +++ b/src/test/ui/consts/issue-17718-constants-not-static.stderr @@ -0,0 +1,12 @@ +error[E0515]: cannot return reference to temporary value + --> $DIR/issue-17718-constants-not-static.rs:5:30 + | +LL | fn foo() -> &'static usize { &id(FOO) } + | ^------- + | || + | |temporary value created here + | returns a reference to data owned by the current function + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/consts/issue-25826.stderr b/src/test/ui/consts/issue-25826.stderr index b80befa26..905c5ee6e 100644 --- a/src/test/ui/consts/issue-25826.stderr +++ b/src/test/ui/consts/issue-25826.stderr @@ -10,10 +10,6 @@ note: the trait `PartialOrd` is implemented for `*const ()`, but that implementa | LL | const A: bool = unsafe { id:: as *const () < id:: as *const () }; | ^ -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | fn main() where *const (): ~const PartialOrd { - | ++++++++++++++++++++++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/consts/issue-32829-2.stderr b/src/test/ui/consts/issue-32829-2.stderr index b94bdc0e3..0fec35818 100644 --- a/src/test/ui/consts/issue-32829-2.stderr +++ b/src/test/ui/consts/issue-32829-2.stderr @@ -13,6 +13,7 @@ LL | invalid(); | ^^^^^^^^^ | = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell error[E0015]: cannot call non-const fn `invalid` in statics --> $DIR/issue-32829-2.rs:54:9 @@ -21,6 +22,7 @@ LL | invalid(); | ^^^^^^^^^ | = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell error: aborting due to 3 previous errors diff --git a/src/test/ui/consts/issue-36163.stderr b/src/test/ui/consts/issue-36163.stderr index 4797d10b7..9ac6c984c 100644 --- a/src/test/ui/consts/issue-36163.stderr +++ b/src/test/ui/consts/issue-36163.stderr @@ -8,7 +8,7 @@ note: ...which requires const-evaluating + checking `A`... --> $DIR/issue-36163.rs:1:1 | LL | const A: isize = Foo::B as isize; - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires const-evaluating + checking `Foo::B::{constant#0}`, completing the cycle note: cycle used when simplifying constant for the type system `Foo::B::{constant#0}` --> $DIR/issue-36163.rs:4:9 diff --git a/src/test/ui/consts/issue-46553.rs b/src/test/ui/consts/issue-46553.rs index 9438df193..abeaf10f2 100644 --- a/src/test/ui/consts/issue-46553.rs +++ b/src/test/ui/consts/issue-46553.rs @@ -1,5 +1,4 @@ // run-pass -#![deny(const_err)] pub struct Data { function: fn() -> T, diff --git a/src/test/ui/consts/issue-56164.rs b/src/test/ui/consts/issue-56164.rs index 094ca377e..df3e3bf90 100644 --- a/src/test/ui/consts/issue-56164.rs +++ b/src/test/ui/consts/issue-56164.rs @@ -1,11 +1,10 @@ const fn foo() { (||{})() } //~^ ERROR cannot call non-const closure -//~| ERROR erroneous constant used [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! +//~| ERROR erroneous constant used const fn bad(input: fn()) { input() - //~^ ERROR function pointer + //~^ ERROR function pointer calls are not allowed } fn main() { diff --git a/src/test/ui/consts/issue-56164.stderr b/src/test/ui/consts/issue-56164.stderr index 73a0f8ec0..c5b2c57fb 100644 --- a/src/test/ui/consts/issue-56164.stderr +++ b/src/test/ui/consts/issue-56164.stderr @@ -8,32 +8,18 @@ LL | const fn foo() { (||{})() } = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: function pointer calls are not allowed in constant functions - --> $DIR/issue-56164.rs:7:5 + --> $DIR/issue-56164.rs:6:5 | LL | input() | ^^^^^^^ -error: erroneous constant used +error[E0080]: erroneous constant used --> $DIR/issue-56164.rs:1:18 | LL | const fn foo() { (||{})() } | ^^^^^^ 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 error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0015`. -Future incompatibility report: Future breakage diagnostic: -error: erroneous constant used - --> $DIR/issue-56164.rs:1:18 - | -LL | const fn foo() { (||{})() } - | ^^^^^^ 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 - +Some errors have detailed explanations: E0015, E0080. +For more information about an error, try `rustc --explain E0015`. diff --git a/src/test/ui/consts/issue-66693.rs b/src/test/ui/consts/issue-66693.rs index 99d28eb77..1ff250be1 100644 --- a/src/test/ui/consts/issue-66693.rs +++ b/src/test/ui/consts/issue-66693.rs @@ -10,8 +10,7 @@ static _FOO: () = panic!(true); const fn _foo() { panic!(&1); //~^ ERROR: argument to `panic!()` in a const context must have type `&str` - //~| ERROR: erroneous constant used [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! + //~| ERROR: erroneous constant used } // ensure that conforming panics don't cause an error diff --git a/src/test/ui/consts/issue-66693.stderr b/src/test/ui/consts/issue-66693.stderr index 5460cc1ee..911374f50 100644 --- a/src/test/ui/consts/issue-66693.stderr +++ b/src/test/ui/consts/issue-66693.stderr @@ -22,26 +22,12 @@ LL | panic!(&1); | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error: erroneous constant used +error[E0080]: erroneous constant used --> $DIR/issue-66693.rs:11:12 | LL | panic!(&1); | ^^ 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 error: aborting due to 4 previous errors -Future incompatibility report: Future breakage diagnostic: -error: erroneous constant used - --> $DIR/issue-66693.rs:11:12 - | -LL | panic!(&1); - | ^^ 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 - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/issue-78655.stderr b/src/test/ui/consts/issue-78655.stderr index f5b1123e7..6b83fa0e5 100644 --- a/src/test/ui/consts/issue-78655.stderr +++ b/src/test/ui/consts/issue-78655.stderr @@ -5,6 +5,11 @@ LL | let x; | - binding declared here but left uninitialized LL | &x | ^^ `x` used here but it isn't initialized + | +help: consider assigning a value + | +LL | let x = 0; + | +++ error: could not evaluate constant pattern --> $DIR/issue-78655.rs:7:9 diff --git a/src/test/ui/consts/issue-88071.rs b/src/test/ui/consts/issue-88071.rs index 1c38c43e6..f58cdb594 100644 --- a/src/test/ui/consts/issue-88071.rs +++ b/src/test/ui/consts/issue-88071.rs @@ -2,8 +2,6 @@ // // regression test for #88071 -#![feature(const_btree_new)] - use std::collections::BTreeMap; pub struct CustomMap(BTreeMap); diff --git a/src/test/ui/consts/issue-94675.rs b/src/test/ui/consts/issue-94675.rs index 0604aab3b..ce21ebdb9 100644 --- a/src/test/ui/consts/issue-94675.rs +++ b/src/test/ui/consts/issue-94675.rs @@ -7,9 +7,8 @@ struct Foo<'a> { impl<'a> Foo<'a> { const fn spam(&mut self, baz: &mut Vec) { self.bar[0] = baz.len(); - //~^ ERROR cannot call non-const fn `Vec::::len` in constant functions - //~| ERROR the trait bound `Vec: ~const IndexMut` is not satisfied - //~| ERROR cannot call non-const operator in constant functions + //~^ the trait bound `Vec: ~const Index<_>` is not satisfied + //~| the trait bound `Vec: ~const IndexMut` is not satisfied } } diff --git a/src/test/ui/consts/issue-94675.stderr b/src/test/ui/consts/issue-94675.stderr index 6665e4283..f4683f7f5 100644 --- a/src/test/ui/consts/issue-94675.stderr +++ b/src/test/ui/consts/issue-94675.stderr @@ -1,10 +1,15 @@ -error[E0015]: cannot call non-const fn `Vec::::len` in constant functions - --> $DIR/issue-94675.rs:9:27 +error[E0277]: the trait bound `Vec: ~const Index<_>` is not satisfied + --> $DIR/issue-94675.rs:9:9 | LL | self.bar[0] = baz.len(); - | ^^^^^ + | ^^^^^^^^^^^ vector indices are of type `usize` or ranges of `usize` + | + = help: the trait `~const Index<_>` is not implemented for `Vec` +note: the trait `Index<_>` is implemented for `Vec`, but that implementation is not `const` + --> $DIR/issue-94675.rs:9:9 | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +LL | self.bar[0] = baz.len(); + | ^^^^^^^^^^^ error[E0277]: the trait bound `Vec: ~const IndexMut` is not satisfied --> $DIR/issue-94675.rs:9:9 @@ -19,20 +24,6 @@ note: the trait `IndexMut` is implemented for `Vec`, but that impl LL | self.bar[0] = baz.len(); | ^^^^^^^^^^^ -error[E0015]: cannot call non-const operator in constant functions - --> $DIR/issue-94675.rs:9:9 - | -LL | self.bar[0] = baz.len(); - | ^^^^^^^^^^^ - | -note: impl defined here, but it is not `const` - --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL - | -LL | impl, A: Allocator> IndexMut for Vec { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/consts/issue-miri-1910.rs b/src/test/ui/consts/issue-miri-1910.rs index 2b23626e3..29e0ea950 100644 --- a/src/test/ui/consts/issue-miri-1910.rs +++ b/src/test/ui/consts/issue-miri-1910.rs @@ -1,4 +1,5 @@ // error-pattern unable to turn pointer into raw bytes +// normalize-stderr-test: "alloc[0-9]+\+0x[a-z0-9]+" -> "ALLOC" #![feature(const_ptr_read)] const C: () = unsafe { diff --git a/src/test/ui/consts/issue-miri-1910.stderr b/src/test/ui/consts/issue-miri-1910.stderr index d953c7819..3872e3d4f 100644 --- a/src/test/ui/consts/issue-miri-1910.stderr +++ b/src/test/ui/consts/issue-miri-1910.stderr @@ -1,47 +1,25 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | unable to turn pointer into raw bytes + | unable to copy parts of a pointer from memory at ALLOC | inside `std::ptr::read::` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - | inside `ptr::const_ptr::::read` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL - | inside `C` at $DIR/issue-miri-1910.rs:7:5 | - ::: $DIR/issue-miri-1910.rs:4:1 + ::: $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | -LL | const C: () = unsafe { - | ----------- +LL | unsafe { read(self) } + | ---------- inside `ptr::const_ptr::::read` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -error: aborting due to previous error - -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL - | -LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | unable to turn pointer into raw bytes - | inside `std::ptr::read::` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - | inside `ptr::const_ptr::::read` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL - | inside `C` at $DIR/issue-miri-1910.rs:7:5 + ::: $DIR/issue-miri-1910.rs:8:5 | - ::: $DIR/issue-miri-1910.rs:4:1 +LL | (&foo as *const _ as *const u8).add(one_and_a_half_pointers).read(); + | ------------------------------------------------------------------- inside `C` at $DIR/issue-miri-1910.rs:8:5 | -LL | const C: () = unsafe { - | ----------- - | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.rs b/src/test/ui/consts/min_const_fn/min_const_fn.rs index 0bafaf2e8..c2891488c 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.rs +++ b/src/test/ui/consts/min_const_fn/min_const_fn.rs @@ -34,7 +34,7 @@ const fn foo35(a: bool, b: bool) -> bool { a ^ b } struct Foo(T); impl Foo { const fn new(t: T) -> Self { Foo(t) } - const fn into_inner(self) -> T { self.0 } //~ destructors cannot be evaluated + const fn into_inner(self) -> T { self.0 } //~ destructor of const fn get(&self) -> &T { &self.0 } const fn get_mut(&mut self) -> &mut T { &mut self.0 } //~^ mutable references @@ -43,7 +43,7 @@ impl Foo { } impl<'a, T> Foo { const fn new_lt(t: T) -> Self { Foo(t) } - const fn into_inner_lt(self) -> T { self.0 } //~ destructors cannot be evaluated + const fn into_inner_lt(self) -> T { self.0 } //~ destructor of const fn get_lt(&'a self) -> &T { &self.0 } const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 } //~^ mutable references @@ -52,7 +52,7 @@ impl<'a, T> Foo { } impl Foo { const fn new_s(t: T) -> Self { Foo(t) } - const fn into_inner_s(self) -> T { self.0 } //~ ERROR destructors + const fn into_inner_s(self) -> T { self.0 } //~ ERROR destructor const fn get_s(&self) -> &T { &self.0 } const fn get_mut_s(&mut self) -> &mut T { &mut self.0 } //~^ mutable references diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.stderr b/src/test/ui/consts/min_const_fn/min_const_fn.stderr index 4ad17602c..11c79e8e2 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.stderr +++ b/src/test/ui/consts/min_const_fn/min_const_fn.stderr @@ -1,10 +1,10 @@ -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Foo` cannot be evaluated at compile-time --> $DIR/min_const_fn.rs:37:25 | LL | const fn into_inner(self) -> T { self.0 } | ^^^^ - value is dropped here | | - | constant functions cannot evaluate destructors + | the destructor for this type cannot be evaluated in constant functions error[E0658]: mutable references are not allowed in constant functions --> $DIR/min_const_fn.rs:39:22 @@ -33,13 +33,13 @@ LL | const fn get_mut(&mut self) -> &mut T { &mut self.0 } = note: see issue #57349 for more information = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Foo` cannot be evaluated at compile-time --> $DIR/min_const_fn.rs:46:28 | LL | const fn into_inner_lt(self) -> T { self.0 } | ^^^^ - value is dropped here | | - | constant functions cannot evaluate destructors + | the destructor for this type cannot be evaluated in constant functions error[E0658]: mutable references are not allowed in constant functions --> $DIR/min_const_fn.rs:48:25 @@ -68,13 +68,13 @@ LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 } = note: see issue #57349 for more information = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Foo` cannot be evaluated at compile-time --> $DIR/min_const_fn.rs:55:27 | LL | const fn into_inner_s(self) -> T { self.0 } | ^^^^ - value is dropped here | | - | constant functions cannot evaluate destructors + | the destructor for this type cannot be evaluated in constant functions error[E0658]: mutable references are not allowed in constant functions --> $DIR/min_const_fn.rs:57:24 @@ -191,21 +191,21 @@ LL | const fn inc(x: &mut i32) { *x += 1 } = note: see issue #57349 for more information = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `AlanTuring` cannot be evaluated at compile-time --> $DIR/min_const_fn.rs:122:19 | LL | const fn no_apit2(_x: AlanTuring) {} | ^^ - value is dropped here | | - | constant functions cannot evaluate destructors + | the destructor for this type cannot be evaluated in constant functions -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `impl std::fmt::Debug` cannot be evaluated at compile-time --> $DIR/min_const_fn.rs:124:18 | LL | const fn no_apit(_x: impl std::fmt::Debug) {} | ^^ - value is dropped here | | - | constant functions cannot evaluate destructors + | the destructor for this type cannot be evaluated in constant functions error: aborting due to 24 previous errors diff --git a/src/test/ui/consts/mir_check_nonconst.stderr b/src/test/ui/consts/mir_check_nonconst.stderr index 2bac995ee..1e0652722 100644 --- a/src/test/ui/consts/mir_check_nonconst.stderr +++ b/src/test/ui/consts/mir_check_nonconst.stderr @@ -5,6 +5,7 @@ LL | static foo: Foo = bar(); | ^^^^^ | = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell error: aborting due to previous error diff --git a/src/test/ui/consts/miri_unleashed/abi-mismatch.rs b/src/test/ui/consts/miri_unleashed/abi-mismatch.rs index 3360e9cac..205f7183b 100644 --- a/src/test/ui/consts/miri_unleashed/abi-mismatch.rs +++ b/src/test/ui/consts/miri_unleashed/abi-mismatch.rs @@ -2,7 +2,6 @@ // compile-flags: -Z unleash-the-miri-inside-of-you #![feature(const_extern_fn)] -#![allow(const_err)] const extern "C" fn c_fn() {} diff --git a/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr b/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr index aaba19c2c..840d698eb 100644 --- a/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr +++ b/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr @@ -1,19 +1,19 @@ error[E0080]: could not evaluate static initializer - --> $DIR/abi-mismatch.rs:10:5 + --> $DIR/abi-mismatch.rs:9:5 | LL | my_fn(); | ^^^^^^^ | | | calling a function with calling convention C using calling convention Rust - | inside `call_rust_fn` at $DIR/abi-mismatch.rs:10:5 + | inside `call_rust_fn` at $DIR/abi-mismatch.rs:9:5 ... LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) }); - | --------------------------------------------------------------------- inside `VAL` at $DIR/abi-mismatch.rs:16:18 + | --------------------------------------------------------------------- inside `VAL` at $DIR/abi-mismatch.rs:15:18 warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/abi-mismatch.rs:10:5 + --> $DIR/abi-mismatch.rs:9:5 | LL | my_fn(); | ^^^^^^^ diff --git a/src/test/ui/consts/miri_unleashed/assoc_const.rs b/src/test/ui/consts/miri_unleashed/assoc_const.rs index 5f520c2cf..76ed667a5 100644 --- a/src/test/ui/consts/miri_unleashed/assoc_const.rs +++ b/src/test/ui/consts/miri_unleashed/assoc_const.rs @@ -1,8 +1,6 @@ // build-fail // compile-flags: -Zunleash-the-miri-inside-of-you -#![allow(const_err)] - // a test demonstrating why we do need to run static const qualification on associated constants // instead of just checking the final constant diff --git a/src/test/ui/consts/miri_unleashed/assoc_const.stderr b/src/test/ui/consts/miri_unleashed/assoc_const.stderr index 1f82ac827..519bd0748 100644 --- a/src/test/ui/consts/miri_unleashed/assoc_const.stderr +++ b/src/test/ui/consts/miri_unleashed/assoc_const.stderr @@ -1,22 +1,4 @@ -error[E0080]: erroneous constant used - --> $DIR/assoc_const.rs:31:13 - | -LL | let y = , String>>::F; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - -warning: skipping const checks - | -help: skipping check that does not even have a feature gate - --> $DIR/assoc_const.rs:14:20 - | -LL | const F: u32 = (U::X, 42).1; - | ^^^^^^^^^^ - -error: aborting due to previous error; 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 +error[E0080]: evaluation of `, std::string::String>>::F` failed --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | LL | pub unsafe fn drop_in_place(to_drop: *mut T) { @@ -25,18 +7,26 @@ LL | pub unsafe fn drop_in_place(to_drop: *mut T) { | calling non-const function ` as Drop>::drop` | inside `std::ptr::drop_in_place::> - shim(Some(Vec))` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL | inside `std::ptr::drop_in_place::<(Vec, u32)> - shim(Some((Vec, u32)))` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - | inside `, String>>::F` at $DIR/assoc_const.rs:14:31 | - ::: $DIR/assoc_const.rs:14:5 + ::: $DIR/assoc_const.rs:12:31 | LL | const F: u32 = (U::X, 42).1; - | ------------ + | - inside `, String>>::F` at $DIR/assoc_const.rs:12:31 + +error[E0080]: erroneous constant used + --> $DIR/assoc_const.rs:29:13 | -note: the lint level is defined here - --> $DIR/assoc_const.rs:4:10 +LL | let y = , String>>::F; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + +warning: skipping const checks | -LL | #![allow(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 +help: skipping check that does not even have a feature gate + --> $DIR/assoc_const.rs:12:20 + | +LL | const F: u32 = (U::X, 42).1; + | ^^^^^^^^^^ + +error: aborting due to 2 previous errors; 1 warning emitted +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/miri_unleashed/assoc_const_2.rs b/src/test/ui/consts/miri_unleashed/assoc_const_2.rs index 30dd2a515..8377141ea 100644 --- a/src/test/ui/consts/miri_unleashed/assoc_const_2.rs +++ b/src/test/ui/consts/miri_unleashed/assoc_const_2.rs @@ -1,7 +1,5 @@ // build-fail -#![allow(const_err)] - // a test demonstrating that const qualification cannot prevent monomorphization time errors trait Foo { @@ -9,7 +7,7 @@ trait Foo { } trait Bar { - const F: u32 = 100 / U::X; + const F: u32 = 100 / U::X; //~ ERROR evaluation of `>::F` failed } impl Foo for () { diff --git a/src/test/ui/consts/miri_unleashed/assoc_const_2.stderr b/src/test/ui/consts/miri_unleashed/assoc_const_2.stderr index cbf02199f..2bf753c2b 100644 --- a/src/test/ui/consts/miri_unleashed/assoc_const_2.stderr +++ b/src/test/ui/consts/miri_unleashed/assoc_const_2.stderr @@ -1,24 +1,15 @@ +error[E0080]: evaluation of `>::F` failed + --> $DIR/assoc_const_2.rs:10:20 + | +LL | const F: u32 = 100 / U::X; + | ^^^^^^^^^^ attempt to divide `100_u32` by zero + error[E0080]: erroneous constant used - --> $DIR/assoc_const_2.rs:29:13 + --> $DIR/assoc_const_2.rs:27:13 | LL | let y = >::F; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors -error: aborting due to previous error +error: aborting due to 2 previous errors 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/assoc_const_2.rs:12:20 - | -LL | const F: u32 = 100 / U::X; - | ------------ ^^^^^^^^^^ attempt to divide `100_u32` by zero - | -note: the lint level is defined here - --> $DIR/assoc_const_2.rs:3:10 - | -LL | #![allow(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 - diff --git a/src/test/ui/consts/miri_unleashed/box.rs b/src/test/ui/consts/miri_unleashed/box.rs index 32796c672..c2a260aa1 100644 --- a/src/test/ui/consts/miri_unleashed/box.rs +++ b/src/test/ui/consts/miri_unleashed/box.rs @@ -1,6 +1,5 @@ // compile-flags: -Zunleash-the-miri-inside-of-you #![feature(box_syntax)] -#![allow(const_err)] use std::mem::ManuallyDrop; diff --git a/src/test/ui/consts/miri_unleashed/box.stderr b/src/test/ui/consts/miri_unleashed/box.stderr index 05d9858dc..bc5d4a257 100644 --- a/src/test/ui/consts/miri_unleashed/box.stderr +++ b/src/test/ui/consts/miri_unleashed/box.stderr @@ -1,5 +1,5 @@ error[E0080]: could not evaluate static initializer - --> $DIR/box.rs:10:11 + --> $DIR/box.rs:9:11 | LL | &mut *(box 0) | ^^^^^^^ calling non-const function `alloc::alloc::exchange_malloc` @@ -7,22 +7,22 @@ LL | &mut *(box 0) warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/box.rs:10:11 + --> $DIR/box.rs:9:11 | LL | &mut *(box 0) | ^^^^^^^ help: skipping check for `const_mut_refs` feature - --> $DIR/box.rs:10:16 + --> $DIR/box.rs:9:16 | LL | &mut *(box 0) | ^ help: skipping check for `const_mut_refs` feature - --> $DIR/box.rs:10:5 + --> $DIR/box.rs:9:5 | LL | &mut *(box 0) | ^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/box.rs:10:5 + --> $DIR/box.rs:9:5 | LL | &mut *(box 0) | ^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static.32bit.stderr b/src/test/ui/consts/miri_unleashed/const_refers_to_static.32bit.stderr new file mode 100644 index 000000000..a6f467b9e --- /dev/null +++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static.32bit.stderr @@ -0,0 +1,81 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/const_refers_to_static.rs:9:5 + | +LL | FOO.fetch_add(1, Ordering::Relaxed) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling non-const function `AtomicUsize::fetch_add` + +error[E0080]: evaluation of constant value failed + --> $DIR/const_refers_to_static.rs:14:14 + | +LL | unsafe { *(&FOO as *const _ as *const usize) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static + +error[E0080]: evaluation of constant value failed + --> $DIR/const_refers_to_static.rs:18:32 + | +LL | const READ_MUT: u32 = unsafe { MUTABLE }; + | ^^^^^^^ constant accesses static + +error[E0080]: it is undefined behavior to use this value + --> $DIR/const_refers_to_static.rs:20:1 + | +LL | const REF_INTERIOR_MUT: &usize = { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 4, align: 4) { + ╾─alloc4──╼ │ ╾──╼ + } + +error[E0080]: it is undefined behavior to use this value + --> $DIR/const_refers_to_static.rs:27:1 + | +LL | const READ_IMMUT: &usize = { + | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 4, align: 4) { + ╾─alloc5──╼ │ ╾──╼ + } + +warning: skipping const checks + | +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static.rs:9:5 + | +LL | FOO.fetch_add(1, Ordering::Relaxed) + | ^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static.rs:9:5 + | +LL | FOO.fetch_add(1, Ordering::Relaxed) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static.rs:14:17 + | +LL | unsafe { *(&FOO as *const _ as *const usize) } + | ^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static.rs:18:32 + | +LL | const READ_MUT: u32 = unsafe { MUTABLE }; + | ^^^^^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static.rs:18:32 + | +LL | const READ_MUT: u32 = unsafe { MUTABLE }; + | ^^^^^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static.rs:23:18 + | +LL | unsafe { &*(&FOO as *const _ as *const usize) } + | ^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static.rs:30:6 + | +LL | &FOO + | ^^^ + +error: aborting due to 5 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static.64bit.stderr b/src/test/ui/consts/miri_unleashed/const_refers_to_static.64bit.stderr new file mode 100644 index 000000000..cfaf31a6e --- /dev/null +++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static.64bit.stderr @@ -0,0 +1,81 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/const_refers_to_static.rs:9:5 + | +LL | FOO.fetch_add(1, Ordering::Relaxed) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling non-const function `AtomicUsize::fetch_add` + +error[E0080]: evaluation of constant value failed + --> $DIR/const_refers_to_static.rs:14:14 + | +LL | unsafe { *(&FOO as *const _ as *const usize) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static + +error[E0080]: evaluation of constant value failed + --> $DIR/const_refers_to_static.rs:18:32 + | +LL | const READ_MUT: u32 = unsafe { MUTABLE }; + | ^^^^^^^ constant accesses static + +error[E0080]: it is undefined behavior to use this value + --> $DIR/const_refers_to_static.rs:20:1 + | +LL | const REF_INTERIOR_MUT: &usize = { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 8, align: 8) { + ╾───────alloc4────────╼ │ ╾──────╼ + } + +error[E0080]: it is undefined behavior to use this value + --> $DIR/const_refers_to_static.rs:27:1 + | +LL | const READ_IMMUT: &usize = { + | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 8, align: 8) { + ╾───────alloc5────────╼ │ ╾──────╼ + } + +warning: skipping const checks + | +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static.rs:9:5 + | +LL | FOO.fetch_add(1, Ordering::Relaxed) + | ^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static.rs:9:5 + | +LL | FOO.fetch_add(1, Ordering::Relaxed) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static.rs:14:17 + | +LL | unsafe { *(&FOO as *const _ as *const usize) } + | ^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static.rs:18:32 + | +LL | const READ_MUT: u32 = unsafe { MUTABLE }; + | ^^^^^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static.rs:18:32 + | +LL | const READ_MUT: u32 = unsafe { MUTABLE }; + | ^^^^^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static.rs:23:18 + | +LL | unsafe { &*(&FOO as *const _ as *const usize) } + | ^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static.rs:30:6 + | +LL | &FOO + | ^^^ + +error: aborting due to 5 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static.rs b/src/test/ui/consts/miri_unleashed/const_refers_to_static.rs index c9dc1de51..7ed5a48d9 100644 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static.rs +++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static.rs @@ -1,31 +1,33 @@ -// build-fail // compile-flags: -Zunleash-the-miri-inside-of-you -#![allow(const_err)] +// stderr-per-bitwidth use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; -// These fail during CTFE (as they read a static), so they only cause an error -// when *using* the const. - const MUTATE_INTERIOR_MUT: usize = { static FOO: AtomicUsize = AtomicUsize::new(0); - FOO.fetch_add(1, Ordering::Relaxed) + FOO.fetch_add(1, Ordering::Relaxed) //~ERROR evaluation of constant value failed }; const READ_INTERIOR_MUT: usize = { static FOO: AtomicUsize = AtomicUsize::new(0); - unsafe { *(&FOO as *const _ as *const usize) } + unsafe { *(&FOO as *const _ as *const usize) } //~ERROR evaluation of constant value failed }; static mut MUTABLE: u32 = 0; -const READ_MUT: u32 = unsafe { MUTABLE }; +const READ_MUT: u32 = unsafe { MUTABLE }; //~ERROR evaluation of constant value failed + +const REF_INTERIOR_MUT: &usize = { //~ ERROR undefined behavior to use this value +//~| encountered a reference pointing to a static variable + static FOO: AtomicUsize = AtomicUsize::new(0); + unsafe { &*(&FOO as *const _ as *const usize) } +}; + +// ok some day perhaps +const READ_IMMUT: &usize = { //~ ERROR it is undefined behavior to use this value +//~| encountered a reference pointing to a static variable + static FOO: usize = 0; + &FOO +}; -fn main() { - MUTATE_INTERIOR_MUT; - //~^ ERROR: erroneous constant used - READ_INTERIOR_MUT; - //~^ ERROR: erroneous constant used - READ_MUT; - //~^ ERROR: erroneous constant used -} +fn main() {} diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static.stderr b/src/test/ui/consts/miri_unleashed/const_refers_to_static.stderr deleted file mode 100644 index fa2088124..000000000 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static.stderr +++ /dev/null @@ -1,100 +0,0 @@ -error[E0080]: erroneous constant used - --> $DIR/const_refers_to_static.rs:25:5 - | -LL | MUTATE_INTERIOR_MUT; - | ^^^^^^^^^^^^^^^^^^^ referenced constant has errors - -error[E0080]: erroneous constant used - --> $DIR/const_refers_to_static.rs:27:5 - | -LL | READ_INTERIOR_MUT; - | ^^^^^^^^^^^^^^^^^ referenced constant has errors - -error[E0080]: erroneous constant used - --> $DIR/const_refers_to_static.rs:29:5 - | -LL | READ_MUT; - | ^^^^^^^^ referenced constant has errors - -warning: skipping const checks - | -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static.rs:13:5 - | -LL | FOO.fetch_add(1, Ordering::Relaxed) - | ^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static.rs:13:5 - | -LL | FOO.fetch_add(1, Ordering::Relaxed) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static.rs:18:17 - | -LL | unsafe { *(&FOO as *const _ as *const usize) } - | ^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static.rs:22:32 - | -LL | const READ_MUT: u32 = unsafe { MUTABLE }; - | ^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static.rs:22:32 - | -LL | const READ_MUT: u32 = unsafe { MUTABLE }; - | ^^^^^^^ - -error: aborting due to 3 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_refers_to_static.rs:13:5 - | -LL | const MUTATE_INTERIOR_MUT: usize = { - | -------------------------------- -LL | static FOO: AtomicUsize = AtomicUsize::new(0); -LL | FOO.fetch_add(1, Ordering::Relaxed) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling non-const function `AtomicUsize::fetch_add` - | -note: the lint level is defined here - --> $DIR/const_refers_to_static.rs:3:10 - | -LL | #![allow(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 - -Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/const_refers_to_static.rs:18:14 - | -LL | const READ_INTERIOR_MUT: usize = { - | ------------------------------ -LL | static FOO: AtomicUsize = AtomicUsize::new(0); -LL | unsafe { *(&FOO as *const _ as *const usize) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static - | -note: the lint level is defined here - --> $DIR/const_refers_to_static.rs:3:10 - | -LL | #![allow(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 - -Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/const_refers_to_static.rs:22:32 - | -LL | const READ_MUT: u32 = unsafe { MUTABLE }; - | ------------------- ^^^^^^^ constant accesses static - | -note: the lint level is defined here - --> $DIR/const_refers_to_static.rs:3:10 - | -LL | #![allow(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 - diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static2.32bit.stderr b/src/test/ui/consts/miri_unleashed/const_refers_to_static2.32bit.stderr deleted file mode 100644 index b3ad81e49..000000000 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static2.32bit.stderr +++ /dev/null @@ -1,38 +0,0 @@ -error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static2.rs:11:1 - | -LL | const REF_INTERIOR_MUT: &usize = { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 4, align: 4) { - ╾─alloc1──╼ │ ╾──╼ - } - -error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static2.rs:18:1 - | -LL | const READ_IMMUT: &usize = { - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 4, align: 4) { - ╾─alloc2──╼ │ ╾──╼ - } - -warning: skipping const checks - | -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static2.rs:14:18 - | -LL | unsafe { &*(&FOO as *const _ as *const usize) } - | ^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static2.rs:21:6 - | -LL | &FOO - | ^^^ - -error: aborting due to 2 previous errors; 1 warning emitted - -For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static2.64bit.stderr b/src/test/ui/consts/miri_unleashed/const_refers_to_static2.64bit.stderr deleted file mode 100644 index 24bd07092..000000000 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static2.64bit.stderr +++ /dev/null @@ -1,38 +0,0 @@ -error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static2.rs:11:1 - | -LL | const REF_INTERIOR_MUT: &usize = { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 8, align: 8) { - ╾───────alloc1────────╼ │ ╾──────╼ - } - -error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static2.rs:18:1 - | -LL | const READ_IMMUT: &usize = { - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 8, align: 8) { - ╾───────alloc2────────╼ │ ╾──────╼ - } - -warning: skipping const checks - | -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static2.rs:14:18 - | -LL | unsafe { &*(&FOO as *const _ as *const usize) } - | ^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static2.rs:21:6 - | -LL | &FOO - | ^^^ - -error: aborting due to 2 previous errors; 1 warning emitted - -For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static2.rs b/src/test/ui/consts/miri_unleashed/const_refers_to_static2.rs deleted file mode 100644 index 8b8e262fb..000000000 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static2.rs +++ /dev/null @@ -1,24 +0,0 @@ -// compile-flags: -Zunleash-the-miri-inside-of-you -// stderr-per-bitwidth -#![allow(const_err)] - -use std::sync::atomic::AtomicUsize; -use std::sync::atomic::Ordering; - -// These only fail during validation (they do not use but just create a reference to a static), -// so they cause an immediate error when *defining* the const. - -const REF_INTERIOR_MUT: &usize = { //~ ERROR undefined behavior to use this value -//~| encountered a reference pointing to a static variable - static FOO: AtomicUsize = AtomicUsize::new(0); - unsafe { &*(&FOO as *const _ as *const usize) } -}; - -// ok some day perhaps -const READ_IMMUT: &usize = { //~ ERROR it is undefined behavior to use this value -//~| encountered a reference pointing to a static variable - static FOO: usize = 0; - &FOO -}; - -fn main() {} diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr index 20a96b57f..6df2fe3d0 100644 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr +++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr @@ -1,8 +1,8 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:12:1 + --> $DIR/const_refers_to_static_cross_crate.rs:10:1 | LL | const SLICE_MUT: &[u8; 1] = { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable + | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { @@ -10,16 +10,16 @@ LL | const SLICE_MUT: &[u8; 1] = { } error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:40:9 + --> $DIR/const_refers_to_static_cross_crate.rs:34:9 | LL | SLICE_MUT => true, | ^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:17:1 + --> $DIR/const_refers_to_static_cross_crate.rs:15:1 | LL | const U8_MUT: &u8 = { - | ^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable + | ^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { @@ -27,75 +27,55 @@ LL | const U8_MUT: &u8 = { } error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:49:9 + --> $DIR/const_refers_to_static_cross_crate.rs:43:9 | LL | U8_MUT => true, | ^^^^^^ -warning: any use of this value will cause an error - --> $DIR/const_refers_to_static_cross_crate.rs:25:15 +error[E0080]: evaluation of constant value failed + --> $DIR/const_refers_to_static_cross_crate.rs:22:15 | -LL | const U8_MUT2: &u8 = { - | ------------------ LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static - | -note: the lint level is defined here - --> $DIR/const_refers_to_static_cross_crate.rs:23:8 - | -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 error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:60:9 + --> $DIR/const_refers_to_static_cross_crate.rs:54:9 | LL | U8_MUT2 => true, | ^^^^^^^ -warning: any use of this value will cause an error - --> $DIR/const_refers_to_static_cross_crate.rs:32:20 +error[E0080]: evaluation of constant value failed + --> $DIR/const_refers_to_static_cross_crate.rs:27:20 | -LL | const U8_MUT3: &u8 = { - | ------------------ LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static - | -note: the lint level is defined here - --> $DIR/const_refers_to_static_cross_crate.rs:30:8 - | -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 error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:68:9 + --> $DIR/const_refers_to_static_cross_crate.rs:62:9 | LL | U8_MUT3 => true, | ^^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:40:9 + --> $DIR/const_refers_to_static_cross_crate.rs:34:9 | LL | SLICE_MUT => true, | ^^^^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:49:9 + --> $DIR/const_refers_to_static_cross_crate.rs:43:9 | LL | U8_MUT => true, | ^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:60:9 + --> $DIR/const_refers_to_static_cross_crate.rs:54:9 | LL | U8_MUT2 => true, | ^^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:68:9 + --> $DIR/const_refers_to_static_cross_crate.rs:62:9 | LL | U8_MUT3 => true, | ^^^^^^^ @@ -103,90 +83,56 @@ LL | U8_MUT3 => true, warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:14:15 + --> $DIR/const_refers_to_static_cross_crate.rs:12:15 | LL | unsafe { &static_cross_crate::ZERO } | ^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:14:15 + --> $DIR/const_refers_to_static_cross_crate.rs:12:15 | LL | unsafe { &static_cross_crate::ZERO } | ^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:19:15 + --> $DIR/const_refers_to_static_cross_crate.rs:17:15 | LL | unsafe { &static_cross_crate::ZERO[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:19:15 + --> $DIR/const_refers_to_static_cross_crate.rs:17:15 | LL | unsafe { &static_cross_crate::ZERO[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:19:15 + --> $DIR/const_refers_to_static_cross_crate.rs:17:15 | LL | unsafe { &static_cross_crate::ZERO[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:25:17 + --> $DIR/const_refers_to_static_cross_crate.rs:22:17 | LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:32:20 + --> $DIR/const_refers_to_static_cross_crate.rs:27:20 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:32:20 + --> $DIR/const_refers_to_static_cross_crate.rs:27:20 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:32:20 + --> $DIR/const_refers_to_static_cross_crate.rs:27:20 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:32:20 + --> $DIR/const_refers_to_static_cross_crate.rs:27:20 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 10 previous errors; 3 warnings emitted +error: aborting due to 12 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_refers_to_static_cross_crate.rs:25:15 - | -LL | const U8_MUT2: &u8 = { - | ------------------ -LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static - | -note: the lint level is defined here - --> $DIR/const_refers_to_static_cross_crate.rs:23:8 - | -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 - -Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/const_refers_to_static_cross_crate.rs:32:20 - | -LL | const U8_MUT3: &u8 = { - | ------------------ -LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static - | -note: the lint level is defined here - --> $DIR/const_refers_to_static_cross_crate.rs:30:8 - | -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 - diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr index dfa0f76ba..8802f3ada 100644 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr +++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr @@ -1,8 +1,8 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:12:1 + --> $DIR/const_refers_to_static_cross_crate.rs:10:1 | LL | const SLICE_MUT: &[u8; 1] = { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable + | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { @@ -10,16 +10,16 @@ LL | const SLICE_MUT: &[u8; 1] = { } error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:40:9 + --> $DIR/const_refers_to_static_cross_crate.rs:34:9 | LL | SLICE_MUT => true, | ^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:17:1 + --> $DIR/const_refers_to_static_cross_crate.rs:15:1 | LL | const U8_MUT: &u8 = { - | ^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable + | ^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { @@ -27,75 +27,55 @@ LL | const U8_MUT: &u8 = { } error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:49:9 + --> $DIR/const_refers_to_static_cross_crate.rs:43:9 | LL | U8_MUT => true, | ^^^^^^ -warning: any use of this value will cause an error - --> $DIR/const_refers_to_static_cross_crate.rs:25:15 +error[E0080]: evaluation of constant value failed + --> $DIR/const_refers_to_static_cross_crate.rs:22:15 | -LL | const U8_MUT2: &u8 = { - | ------------------ LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static - | -note: the lint level is defined here - --> $DIR/const_refers_to_static_cross_crate.rs:23:8 - | -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 error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:60:9 + --> $DIR/const_refers_to_static_cross_crate.rs:54:9 | LL | U8_MUT2 => true, | ^^^^^^^ -warning: any use of this value will cause an error - --> $DIR/const_refers_to_static_cross_crate.rs:32:20 +error[E0080]: evaluation of constant value failed + --> $DIR/const_refers_to_static_cross_crate.rs:27:20 | -LL | const U8_MUT3: &u8 = { - | ------------------ LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static - | -note: the lint level is defined here - --> $DIR/const_refers_to_static_cross_crate.rs:30:8 - | -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 error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:68:9 + --> $DIR/const_refers_to_static_cross_crate.rs:62:9 | LL | U8_MUT3 => true, | ^^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:40:9 + --> $DIR/const_refers_to_static_cross_crate.rs:34:9 | LL | SLICE_MUT => true, | ^^^^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:49:9 + --> $DIR/const_refers_to_static_cross_crate.rs:43:9 | LL | U8_MUT => true, | ^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:60:9 + --> $DIR/const_refers_to_static_cross_crate.rs:54:9 | LL | U8_MUT2 => true, | ^^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:68:9 + --> $DIR/const_refers_to_static_cross_crate.rs:62:9 | LL | U8_MUT3 => true, | ^^^^^^^ @@ -103,90 +83,56 @@ LL | U8_MUT3 => true, warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:14:15 + --> $DIR/const_refers_to_static_cross_crate.rs:12:15 | LL | unsafe { &static_cross_crate::ZERO } | ^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:14:15 + --> $DIR/const_refers_to_static_cross_crate.rs:12:15 | LL | unsafe { &static_cross_crate::ZERO } | ^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:19:15 + --> $DIR/const_refers_to_static_cross_crate.rs:17:15 | LL | unsafe { &static_cross_crate::ZERO[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:19:15 + --> $DIR/const_refers_to_static_cross_crate.rs:17:15 | LL | unsafe { &static_cross_crate::ZERO[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:19:15 + --> $DIR/const_refers_to_static_cross_crate.rs:17:15 | LL | unsafe { &static_cross_crate::ZERO[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:25:17 + --> $DIR/const_refers_to_static_cross_crate.rs:22:17 | LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:32:20 + --> $DIR/const_refers_to_static_cross_crate.rs:27:20 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:32:20 + --> $DIR/const_refers_to_static_cross_crate.rs:27:20 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:32:20 + --> $DIR/const_refers_to_static_cross_crate.rs:27:20 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:32:20 + --> $DIR/const_refers_to_static_cross_crate.rs:27:20 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 10 previous errors; 3 warnings emitted +error: aborting due to 12 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_refers_to_static_cross_crate.rs:25:15 - | -LL | const U8_MUT2: &u8 = { - | ------------------ -LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static - | -note: the lint level is defined here - --> $DIR/const_refers_to_static_cross_crate.rs:23:8 - | -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 - -Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/const_refers_to_static_cross_crate.rs:32:20 - | -LL | const U8_MUT3: &u8 = { - | ------------------ -LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static - | -note: the lint level is defined here - --> $DIR/const_refers_to_static_cross_crate.rs:30:8 - | -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 - diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs index 4638d73fc..bf4f14f4d 100644 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs +++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs @@ -1,9 +1,7 @@ // compile-flags: -Zunleash-the-miri-inside-of-you // aux-build:static_cross_crate.rs // stderr-per-bitwidth -#![allow(const_err)] - -#![feature(exclusive_range_pattern, half_open_range_patterns)] +#![feature(exclusive_range_pattern, half_open_range_patterns_in_slices)] extern crate static_cross_crate; @@ -19,20 +17,16 @@ const U8_MUT: &u8 = { //~ ERROR undefined behavior to use this value unsafe { &static_cross_crate::ZERO[0] } }; -// Also test indirection that reads from other static. This causes a const_err. -#[warn(const_err)] +// Also test indirection that reads from other static. const U8_MUT2: &u8 = { unsafe { &(*static_cross_crate::ZERO_REF)[0] } - //~^ WARN [const_err] + //~^ ERROR evaluation of constant value failed //~| constant accesses static - //~| WARN this was previously accepted by the compiler but is being phased out }; -#[warn(const_err)] const U8_MUT3: &u8 = { unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } - //~^ WARN [const_err] + //~^ ERROR evaluation of constant value failed //~| constant accesses static - //~| WARN this was previously accepted by the compiler but is being phased out }; pub fn test(x: &[u8; 1]) -> bool { diff --git a/src/test/ui/consts/miri_unleashed/drop.rs b/src/test/ui/consts/miri_unleashed/drop.rs index 4afa954d9..3942e7ef7 100644 --- a/src/test/ui/consts/miri_unleashed/drop.rs +++ b/src/test/ui/consts/miri_unleashed/drop.rs @@ -1,6 +1,5 @@ // compile-flags: -Zunleash-the-miri-inside-of-you // error-pattern: calling non-const function ` as Drop>::drop` -#![allow(const_err)] use std::mem::ManuallyDrop; diff --git a/src/test/ui/consts/miri_unleashed/drop.stderr b/src/test/ui/consts/miri_unleashed/drop.stderr index 36db6b786..a3a502723 100644 --- a/src/test/ui/consts/miri_unleashed/drop.stderr +++ b/src/test/ui/consts/miri_unleashed/drop.stderr @@ -7,15 +7,15 @@ LL | pub unsafe fn drop_in_place(to_drop: *mut T) { | calling non-const function ` as Drop>::drop` | inside `std::ptr::drop_in_place::> - shim(Some(Vec))` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL | - ::: $DIR/drop.rs:18:1 + ::: $DIR/drop.rs:17:1 | LL | }; - | - inside `TEST_BAD` at $DIR/drop.rs:18:1 + | - inside `TEST_BAD` at $DIR/drop.rs:17:1 warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/drop.rs:17:9 + --> $DIR/drop.rs:16:9 | LL | let _v: Vec = Vec::new(); | ^^ diff --git a/src/test/ui/consts/miri_unleashed/feature-gate-unleash_the_miri_inside_of_you.rs b/src/test/ui/consts/miri_unleashed/feature-gate-unleash_the_miri_inside_of_you.rs index 8b17f6885..c24d3338e 100644 --- a/src/test/ui/consts/miri_unleashed/feature-gate-unleash_the_miri_inside_of_you.rs +++ b/src/test/ui/consts/miri_unleashed/feature-gate-unleash_the_miri_inside_of_you.rs @@ -1,5 +1,3 @@ -#![allow(const_err)] - // a test demonstrating why we do need to run static const qualification on associated constants // instead of just checking the final constant @@ -8,7 +6,7 @@ trait Foo { } trait Bar> { - const F: u32 = (U::X, 42).1; //~ ERROR destructors cannot be evaluated at compile-time + const F: u32 = (U::X, 42).1; //~ ERROR destructor of } impl Foo for () { diff --git a/src/test/ui/consts/miri_unleashed/feature-gate-unleash_the_miri_inside_of_you.stderr b/src/test/ui/consts/miri_unleashed/feature-gate-unleash_the_miri_inside_of_you.stderr index 0b6cb2fab..45ed88b1b 100644 --- a/src/test/ui/consts/miri_unleashed/feature-gate-unleash_the_miri_inside_of_you.stderr +++ b/src/test/ui/consts/miri_unleashed/feature-gate-unleash_the_miri_inside_of_you.stderr @@ -1,10 +1,10 @@ -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/feature-gate-unleash_the_miri_inside_of_you.rs:11:20 +error[E0493]: destructor of `(T, u32)` cannot be evaluated at compile-time + --> $DIR/feature-gate-unleash_the_miri_inside_of_you.rs:9:20 | LL | const F: u32 = (U::X, 42).1; | ^^^^^^^^^^ - value is dropped here | | - | constants cannot evaluate destructors + | the destructor for this type cannot be evaluated in constants error: aborting due to previous error diff --git a/src/test/ui/consts/miri_unleashed/inline_asm.rs b/src/test/ui/consts/miri_unleashed/inline_asm.rs index 697117033..6fd52ceb2 100644 --- a/src/test/ui/consts/miri_unleashed/inline_asm.rs +++ b/src/test/ui/consts/miri_unleashed/inline_asm.rs @@ -1,6 +1,5 @@ // compile-flags: -Zunleash-the-miri-inside-of-you // only-x86_64 -#![allow(const_err)] use std::arch::asm; diff --git a/src/test/ui/consts/miri_unleashed/inline_asm.stderr b/src/test/ui/consts/miri_unleashed/inline_asm.stderr index 595b859cb..6317cd882 100644 --- a/src/test/ui/consts/miri_unleashed/inline_asm.stderr +++ b/src/test/ui/consts/miri_unleashed/inline_asm.stderr @@ -1,5 +1,5 @@ error[E0080]: could not evaluate static initializer - --> $DIR/inline_asm.rs:11:14 + --> $DIR/inline_asm.rs:10:14 | LL | unsafe { asm!("nop"); } | ^^^^^^^^^^^ inline assembly is not supported @@ -7,7 +7,7 @@ LL | unsafe { asm!("nop"); } warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/inline_asm.rs:11:14 + --> $DIR/inline_asm.rs:10:14 | LL | unsafe { asm!("nop"); } | ^^^^^^^^^^^ diff --git a/src/test/ui/consts/miri_unleashed/mutable_references.rs b/src/test/ui/consts/miri_unleashed/mutable_references.rs index ca927ef4a..4e9964647 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_references.rs +++ b/src/test/ui/consts/miri_unleashed/mutable_references.rs @@ -1,5 +1,4 @@ // compile-flags: -Zunleash-the-miri-inside-of-you -#![allow(const_err)] use std::cell::UnsafeCell; diff --git a/src/test/ui/consts/miri_unleashed/mutable_references.stderr b/src/test/ui/consts/miri_unleashed/mutable_references.stderr index c6180c1e0..3ed96701a 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_references.stderr +++ b/src/test/ui/consts/miri_unleashed/mutable_references.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item - --> $DIR/mutable_references.rs:36:5 + --> $DIR/mutable_references.rs:35:5 | LL | *OH_YES = 99; | ^^^^^^^^^^^^ cannot assign @@ -7,27 +7,27 @@ LL | *OH_YES = 99; warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:9:26 + --> $DIR/mutable_references.rs:8:26 | LL | static FOO: &&mut u32 = &&mut 42; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:13:23 + --> $DIR/mutable_references.rs:12:23 | LL | static BAR: &mut () = &mut (); | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:18:28 + --> $DIR/mutable_references.rs:17:28 | LL | static BOO: &mut Foo<()> = &mut Foo(()); | ^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:26:8 + --> $DIR/mutable_references.rs:25:8 | LL | x: &UnsafeCell::new(42), | ^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:30:27 + --> $DIR/mutable_references.rs:29:27 | LL | static OH_YES: &mut i32 = &mut 42; | ^^^^^^^ diff --git a/src/test/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr b/src/test/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr index 7ea35f70d..0ea179240 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr +++ b/src/test/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references_err.rs:17:1 + --> $DIR/mutable_references_err.rs:15:1 | LL | const MUH: Meh = Meh { | ^^^^^^^^^^^^^^ constructing invalid value at .x.: encountered `UnsafeCell` in a `const` @@ -10,7 +10,7 @@ LL | const MUH: Meh = Meh { } error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references_err.rs:27:1 + --> $DIR/mutable_references_err.rs:25:1 | LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ...x: encountered `UnsafeCell` in a `const` @@ -21,7 +21,7 @@ LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references_err.rs:31:1 + --> $DIR/mutable_references_err.rs:29:1 | LL | const BLUNT: &mut i32 = &mut 42; | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` @@ -34,17 +34,17 @@ LL | const BLUNT: &mut i32 = &mut 42; warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:18:8 + --> $DIR/mutable_references_err.rs:16:8 | LL | x: &UnsafeCell::new(42), | ^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:27:27 + --> $DIR/mutable_references_err.rs:25:27 | LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:31:25 + --> $DIR/mutable_references_err.rs:29:25 | LL | const BLUNT: &mut i32 = &mut 42; | ^^^^^^^ diff --git a/src/test/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr b/src/test/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr index 5ad398930..67959d256 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr +++ b/src/test/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references_err.rs:17:1 + --> $DIR/mutable_references_err.rs:15:1 | LL | const MUH: Meh = Meh { | ^^^^^^^^^^^^^^ constructing invalid value at .x.: encountered `UnsafeCell` in a `const` @@ -10,7 +10,7 @@ LL | const MUH: Meh = Meh { } error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references_err.rs:27:1 + --> $DIR/mutable_references_err.rs:25:1 | LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ...x: encountered `UnsafeCell` in a `const` @@ -21,7 +21,7 @@ LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references_err.rs:31:1 + --> $DIR/mutable_references_err.rs:29:1 | LL | const BLUNT: &mut i32 = &mut 42; | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` @@ -34,17 +34,17 @@ LL | const BLUNT: &mut i32 = &mut 42; warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:18:8 + --> $DIR/mutable_references_err.rs:16:8 | LL | x: &UnsafeCell::new(42), | ^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:27:27 + --> $DIR/mutable_references_err.rs:25:27 | LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:31:25 + --> $DIR/mutable_references_err.rs:29:25 | LL | const BLUNT: &mut i32 = &mut 42; | ^^^^^^^ diff --git a/src/test/ui/consts/miri_unleashed/mutable_references_err.rs b/src/test/ui/consts/miri_unleashed/mutable_references_err.rs index 722b9cf94..6399b122b 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_references_err.rs +++ b/src/test/ui/consts/miri_unleashed/mutable_references_err.rs @@ -1,8 +1,6 @@ // stderr-per-bitwidth // compile-flags: -Zunleash-the-miri-inside-of-you -#![allow(const_err)] - use std::cell::UnsafeCell; // this test ensures that our mutability story is sound diff --git a/src/test/ui/consts/miri_unleashed/mutating_global.rs b/src/test/ui/consts/miri_unleashed/mutating_global.rs index 902fe0aa1..231f4af0a 100644 --- a/src/test/ui/consts/miri_unleashed/mutating_global.rs +++ b/src/test/ui/consts/miri_unleashed/mutating_global.rs @@ -1,5 +1,4 @@ // compile-flags: -Zunleash-the-miri-inside-of-you -#![allow(const_err)] // Make sure we cannot mutate globals. diff --git a/src/test/ui/consts/miri_unleashed/mutating_global.stderr b/src/test/ui/consts/miri_unleashed/mutating_global.stderr index ba9dd5619..c8770c8d7 100644 --- a/src/test/ui/consts/miri_unleashed/mutating_global.stderr +++ b/src/test/ui/consts/miri_unleashed/mutating_global.stderr @@ -1,5 +1,5 @@ error[E0080]: could not evaluate static initializer - --> $DIR/mutating_global.rs:10:9 + --> $DIR/mutating_global.rs:9:9 | LL | GLOBAL = 99 | ^^^^^^^^^^^ modifying a static's initial value from another static's initializer diff --git a/src/test/ui/consts/miri_unleashed/non_const_fn.rs b/src/test/ui/consts/miri_unleashed/non_const_fn.rs index 70da94df7..44ab60dca 100644 --- a/src/test/ui/consts/miri_unleashed/non_const_fn.rs +++ b/src/test/ui/consts/miri_unleashed/non_const_fn.rs @@ -1,7 +1,5 @@ // compile-flags: -Zunleash-the-miri-inside-of-you -#![allow(const_err)] - // A test demonstrating that we prevent calling non-const fn during CTFE. fn foo() {} diff --git a/src/test/ui/consts/miri_unleashed/non_const_fn.stderr b/src/test/ui/consts/miri_unleashed/non_const_fn.stderr index 3e9658ad8..57836f796 100644 --- a/src/test/ui/consts/miri_unleashed/non_const_fn.stderr +++ b/src/test/ui/consts/miri_unleashed/non_const_fn.stderr @@ -1,5 +1,5 @@ error[E0080]: could not evaluate static initializer - --> $DIR/non_const_fn.rs:9:16 + --> $DIR/non_const_fn.rs:7:16 | LL | static C: () = foo(); | ^^^^^ calling non-const function `foo` @@ -7,7 +7,7 @@ LL | static C: () = foo(); warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/non_const_fn.rs:9:16 + --> $DIR/non_const_fn.rs:7:16 | LL | static C: () = foo(); | ^^^^^ diff --git a/src/test/ui/consts/miri_unleashed/ptr_arith.rs b/src/test/ui/consts/miri_unleashed/ptr_arith.rs index 13e6af36e..4d12960b8 100644 --- a/src/test/ui/consts/miri_unleashed/ptr_arith.rs +++ b/src/test/ui/consts/miri_unleashed/ptr_arith.rs @@ -1,6 +1,5 @@ // compile-flags: -Zunleash-the-miri-inside-of-you #![feature(core_intrinsics)] -#![allow(const_err)] // During CTFE, we prevent pointer-to-int casts. // Pointer comparisons are prevented in the trait system. @@ -8,7 +7,7 @@ static PTR_INT_CAST: () = { let x = &0 as *const _ as usize; //~^ ERROR could not evaluate static initializer - //~| "exposing pointers" needs an rfc before being allowed inside constants + //~| exposing pointers let _v = x == x; }; @@ -19,4 +18,7 @@ static PTR_INT_TRANSMUTE: () = unsafe { //~| unable to turn pointer into raw bytes }; +// I'd love to test pointer comparison, but that is not possible since +// their `PartialEq` impl is non-`const`. + fn main() {} diff --git a/src/test/ui/consts/miri_unleashed/ptr_arith.stderr b/src/test/ui/consts/miri_unleashed/ptr_arith.stderr index f67ac4802..30fd3a55e 100644 --- a/src/test/ui/consts/miri_unleashed/ptr_arith.stderr +++ b/src/test/ui/consts/miri_unleashed/ptr_arith.stderr @@ -1,11 +1,11 @@ error[E0080]: could not evaluate static initializer - --> $DIR/ptr_arith.rs:9:13 + --> $DIR/ptr_arith.rs:8:13 | LL | let x = &0 as *const _ as usize; - | ^^^^^^^^^^^^^^^^^^^^^^^ "exposing pointers" needs an rfc before being allowed inside constants + | ^^^^^^^^^^^^^^^^^^^^^^^ exposing pointers is not possible at compile-time error[E0080]: could not evaluate static initializer - --> $DIR/ptr_arith.rs:17:14 + --> $DIR/ptr_arith.rs:16:14 | LL | let _v = x + 0; | ^ unable to turn pointer into raw bytes @@ -16,7 +16,7 @@ LL | let _v = x + 0; warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/ptr_arith.rs:9:13 + --> $DIR/ptr_arith.rs:8:13 | LL | let x = &0 as *const _ as usize; | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/miri_unleashed/raw_mutable_const.rs b/src/test/ui/consts/miri_unleashed/raw_mutable_const.rs index cabd754e0..5f8ec4e6e 100644 --- a/src/test/ui/consts/miri_unleashed/raw_mutable_const.rs +++ b/src/test/ui/consts/miri_unleashed/raw_mutable_const.rs @@ -1,7 +1,5 @@ // compile-flags: -Zunleash-the-miri-inside-of-you -#![allow(const_err)] - use std::cell::UnsafeCell; const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; diff --git a/src/test/ui/consts/miri_unleashed/raw_mutable_const.stderr b/src/test/ui/consts/miri_unleashed/raw_mutable_const.stderr index e145f6dd2..f8dc11d69 100644 --- a/src/test/ui/consts/miri_unleashed/raw_mutable_const.stderr +++ b/src/test/ui/consts/miri_unleashed/raw_mutable_const.stderr @@ -1,5 +1,5 @@ error: untyped pointers are not allowed in constant - --> $DIR/raw_mutable_const.rs:7:1 + --> $DIR/raw_mutable_const.rs:5:1 | LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *m warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/raw_mutable_const.rs:7:38 + --> $DIR/raw_mutable_const.rs:5:38 | LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/miri_unleashed/slice_eq.rs b/src/test/ui/consts/miri_unleashed/slice_eq.rs index fd843105d..83e10bf12 100644 --- a/src/test/ui/consts/miri_unleashed/slice_eq.rs +++ b/src/test/ui/consts/miri_unleashed/slice_eq.rs @@ -4,14 +4,10 @@ #![feature(const_raw_ptr_comparison)] const EMPTY_SLICE: &[i32] = &[]; -const EMPTY_EQ: bool = EMPTY_SLICE.as_ptr().guaranteed_eq(&[] as *const _); -const EMPTY_EQ2: bool = EMPTY_SLICE.as_ptr().guaranteed_ne(&[] as *const _); -const EMPTY_NE: bool = EMPTY_SLICE.as_ptr().guaranteed_ne(&[1] as *const _); -const EMPTY_NE2: bool = EMPTY_SLICE.as_ptr().guaranteed_eq(&[1] as *const _); +const EMPTY_EQ: Option = EMPTY_SLICE.as_ptr().guaranteed_eq(&[] as *const _); +const EMPTY_EQ2: Option = EMPTY_SLICE.as_ptr().guaranteed_eq(&[1] as *const _); fn main() { - assert!(!EMPTY_EQ); - assert!(!EMPTY_EQ2); - assert!(!EMPTY_NE); - assert!(!EMPTY_NE2); + assert!(EMPTY_EQ.is_none()); + assert!(EMPTY_EQ2.is_none()); } diff --git a/src/test/ui/consts/miri_unleashed/tls.rs b/src/test/ui/consts/miri_unleashed/tls.rs index 7d4f8962a..d06d7cf19 100644 --- a/src/test/ui/consts/miri_unleashed/tls.rs +++ b/src/test/ui/consts/miri_unleashed/tls.rs @@ -1,6 +1,5 @@ // compile-flags: -Zunleash-the-miri-inside-of-you #![feature(thread_local)] -#![allow(const_err)] use std::thread; diff --git a/src/test/ui/consts/miri_unleashed/tls.stderr b/src/test/ui/consts/miri_unleashed/tls.stderr index a49e50a3e..436c51123 100644 --- a/src/test/ui/consts/miri_unleashed/tls.stderr +++ b/src/test/ui/consts/miri_unleashed/tls.stderr @@ -1,11 +1,11 @@ error[E0080]: could not evaluate static initializer - --> $DIR/tls.rs:12:25 + --> $DIR/tls.rs:11:25 | LL | unsafe { let _val = A; } | ^ cannot access thread local static (DefId(0:6 ~ tls[78b0]::A)) error[E0080]: could not evaluate static initializer - --> $DIR/tls.rs:19:26 + --> $DIR/tls.rs:18:26 | LL | unsafe { let _val = &A; } | ^ cannot access thread local static (DefId(0:6 ~ tls[78b0]::A)) @@ -13,12 +13,12 @@ LL | unsafe { let _val = &A; } warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/tls.rs:12:25 + --> $DIR/tls.rs:11:25 | LL | unsafe { let _val = A; } | ^ help: skipping check that does not even have a feature gate - --> $DIR/tls.rs:19:26 + --> $DIR/tls.rs:18:26 | LL | unsafe { let _val = &A; } | ^ diff --git a/src/test/ui/consts/offset.rs b/src/test/ui/consts/offset.rs index f9ddda554..b2c663fe6 100644 --- a/src/test/ui/consts/offset.rs +++ b/src/test/ui/consts/offset.rs @@ -1,5 +1,4 @@ // run-pass -#![feature(const_ptr_offset_from)] use std::ptr; #[repr(C)] diff --git a/src/test/ui/consts/offset_from.rs b/src/test/ui/consts/offset_from.rs index b53718316..465147041 100644 --- a/src/test/ui/consts/offset_from.rs +++ b/src/test/ui/consts/offset_from.rs @@ -1,6 +1,5 @@ // run-pass -#![feature(const_ptr_offset_from)] #![feature(const_ptr_sub_ptr)] #![feature(ptr_sub_ptr)] diff --git a/src/test/ui/consts/offset_from_ub.rs b/src/test/ui/consts/offset_from_ub.rs index 1f29a6905..51163e650 100644 --- a/src/test/ui/consts/offset_from_ub.rs +++ b/src/test/ui/consts/offset_from_ub.rs @@ -1,4 +1,4 @@ -#![feature(const_ptr_offset_from)] +#![feature(const_ptr_sub_ptr)] #![feature(core_intrinsics)] use std::intrinsics::{ptr_offset_from, ptr_offset_from_unsigned}; diff --git a/src/test/ui/consts/promote-not.rs b/src/test/ui/consts/promote-not.rs index 6830b23cf..907617052 100644 --- a/src/test/ui/consts/promote-not.rs +++ b/src/test/ui/consts/promote-not.rs @@ -1,6 +1,6 @@ // ignore-tidy-linelength // Test various things that we do not want to promote. -#![allow(unconditional_panic, const_err)] +#![allow(unconditional_panic)] use std::cell::Cell; diff --git a/src/test/ui/consts/ptr_comparisons.rs b/src/test/ui/consts/ptr_comparisons.rs index 20233db09..f442e6138 100644 --- a/src/test/ui/consts/ptr_comparisons.rs +++ b/src/test/ui/consts/ptr_comparisons.rs @@ -14,38 +14,30 @@ const FOO: &usize = &42; macro_rules! check { (eq, $a:expr, $b:expr) => { pub const _: () = - assert!(std::intrinsics::ptr_guaranteed_eq($a as *const u8, $b as *const u8)); + assert!(std::intrinsics::ptr_guaranteed_cmp($a as *const u8, $b as *const u8) == 1); }; (ne, $a:expr, $b:expr) => { pub const _: () = - assert!(std::intrinsics::ptr_guaranteed_ne($a as *const u8, $b as *const u8)); + assert!(std::intrinsics::ptr_guaranteed_cmp($a as *const u8, $b as *const u8) == 0); }; - (!eq, $a:expr, $b:expr) => { + (!, $a:expr, $b:expr) => { pub const _: () = - assert!(!std::intrinsics::ptr_guaranteed_eq($a as *const u8, $b as *const u8)); - }; - (!ne, $a:expr, $b:expr) => { - pub const _: () = - assert!(!std::intrinsics::ptr_guaranteed_ne($a as *const u8, $b as *const u8)); + assert!(std::intrinsics::ptr_guaranteed_cmp($a as *const u8, $b as *const u8) == 2); }; } check!(eq, 0, 0); check!(ne, 0, 1); -check!(!eq, 0, 1); -check!(!ne, 0, 0); check!(ne, FOO as *const _, 0); -check!(!eq, FOO as *const _, 0); +check!(ne, unsafe { (FOO as *const usize).offset(1) }, 0); +check!(ne, unsafe { (FOO as *const usize as *const u8).offset(3) }, 0); + // We want pointers to be equal to themselves, but aren't checking this yet because // there are some open questions (e.g. whether function pointers to the same function // compare equal, they don't necessarily at runtime). // The case tested here should work eventually, but does not work yet. -check!(!eq, FOO as *const _, FOO as *const _); -check!(ne, unsafe { (FOO as *const usize).offset(1) }, 0); -check!(!eq, unsafe { (FOO as *const usize).offset(1) }, 0); +check!(!, FOO as *const _, FOO as *const _); -check!(ne, unsafe { (FOO as *const usize as *const u8).offset(3) }, 0); -check!(!eq, unsafe { (FOO as *const usize as *const u8).offset(3) }, 0); /////////////////////////////////////////////////////////////////////////////// // If any of the below start compiling, make sure to add a `check` test for it. @@ -63,11 +55,9 @@ const _: *const u8 = //~| out-of-bounds const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + 4 }; -//~^ ERROR any use of this value will cause an error +//~^ ERROR evaluation of constant value failed //~| unable to turn pointer into raw bytes -//~| WARN this was previously accepted by the compiler but is being phased out const _: usize = unsafe { *std::mem::transmute::<&&usize, &usize>(&FOO) + 4 }; -//~^ ERROR any use of this value will cause an error +//~^ ERROR evaluation of constant value failed //~| unable to turn pointer into raw bytes -//~| WARN this was previously accepted by the compiler but is being phased out diff --git a/src/test/ui/consts/ptr_comparisons.stderr b/src/test/ui/consts/ptr_comparisons.stderr index 1d47f243f..b71964b92 100644 --- a/src/test/ui/consts/ptr_comparisons.stderr +++ b/src/test/ui/consts/ptr_comparisons.stderr @@ -7,66 +7,35 @@ LL | unsafe { intrinsics::offset(self, count) } | out-of-bounds pointer arithmetic: alloc3 has size $WORD, so pointer to $TWO_WORDS bytes starting at offset 0 is out-of-bounds | inside `ptr::const_ptr::::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - ::: $DIR/ptr_comparisons.rs:58:34 + ::: $DIR/ptr_comparisons.rs:50:34 | LL | const _: *const usize = unsafe { (FOO as *const usize).offset(2) }; - | ------------------------------- inside `_` at $DIR/ptr_comparisons.rs:58:34 + | ------------------------------- inside `_` at $DIR/ptr_comparisons.rs:50:34 error[E0080]: evaluation of constant value failed - --> $DIR/ptr_comparisons.rs:61:33 + --> $DIR/ptr_comparisons.rs:53:33 | LL | unsafe { std::ptr::addr_of!((*(FOO as *const usize as *const [u8; 1000]))[999]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: alloc3 has size $WORD, so pointer to 1000 bytes starting at offset 0 is out-of-bounds -error: any use of this value will cause an error - --> $DIR/ptr_comparisons.rs:65:27 +error[E0080]: evaluation of constant value failed + --> $DIR/ptr_comparisons.rs:57:27 | LL | const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + 4 }; - | -------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: any use of this value will cause an error - --> $DIR/ptr_comparisons.rs:70:27 +error[E0080]: evaluation of constant value failed + --> $DIR/ptr_comparisons.rs:61:27 | LL | const _: usize = unsafe { *std::mem::transmute::<&&usize, &usize>(&FOO) + 4 }; - | -------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = 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 = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error: aborting due to 4 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/ptr_comparisons.rs:65:27 - | -LL | const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + 4 }; - | -------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ptr_comparisons.rs:70:27 - | -LL | const _: usize = unsafe { *std::mem::transmute::<&&usize, &usize>(&FOO) + 4 }; - | -------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = 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 - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - diff --git a/src/test/ui/consts/qualif-indirect-mutation-fail.rs b/src/test/ui/consts/qualif-indirect-mutation-fail.rs index f74a25a34..a6d293404 100644 --- a/src/test/ui/consts/qualif-indirect-mutation-fail.rs +++ b/src/test/ui/consts/qualif-indirect-mutation-fail.rs @@ -6,13 +6,13 @@ // Mutable borrow of a field with drop impl. pub const fn f() { - let mut a: (u32, Option) = (0, None); //~ ERROR destructors cannot be evaluated + let mut a: (u32, Option) = (0, None); //~ ERROR destructor of let _ = &mut a.1; } // Mutable borrow of a type with drop impl. pub const A1: () = { - let mut x = None; //~ ERROR destructors cannot be evaluated + let mut x = None; //~ ERROR destructor of let mut y = Some(String::new()); let a = &mut x; let b = &mut y; @@ -28,12 +28,12 @@ pub const A2: () = { let b = &mut y; std::mem::swap(a, b); std::mem::forget(y); - let _z = x; //~ ERROR destructors cannot be evaluated + let _z = x; //~ ERROR destructor of }; // Shared borrow of a type that might be !Freeze and Drop. pub const fn g1() { - let x: Option = None; //~ ERROR destructors cannot be evaluated + let x: Option = None; //~ ERROR destructor of let _ = x.is_some(); } @@ -41,24 +41,24 @@ pub const fn g1() { pub const fn g2() { let x: Option = None; let _ = x.is_some(); - let _y = x; //~ ERROR destructors cannot be evaluated + let _y = x; //~ ERROR destructor of } // Mutable raw reference to a Drop type. pub const fn address_of_mut() { - let mut x: Option = None; //~ ERROR destructors cannot be evaluated + let mut x: Option = None; //~ ERROR destructor of &raw mut x; - let mut y: Option = None; //~ ERROR destructors cannot be evaluated + let mut y: Option = None; //~ ERROR destructor of std::ptr::addr_of_mut!(y); } // Const raw reference to a Drop type. Conservatively assumed to allow mutation // until resolution of https://github.com/rust-lang/rust/issues/56604. pub const fn address_of_const() { - let x: Option = None; //~ ERROR destructors cannot be evaluated + let x: Option = None; //~ ERROR destructor of &raw const x; - let y: Option = None; //~ ERROR destructors cannot be evaluated + let y: Option = None; //~ ERROR destructor of std::ptr::addr_of!(y); } diff --git a/src/test/ui/consts/qualif-indirect-mutation-fail.stderr b/src/test/ui/consts/qualif-indirect-mutation-fail.stderr index 713df12b7..6379c00e4 100644 --- a/src/test/ui/consts/qualif-indirect-mutation-fail.stderr +++ b/src/test/ui/consts/qualif-indirect-mutation-fail.stderr @@ -1,56 +1,56 @@ -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `(u32, Option)` cannot be evaluated at compile-time --> $DIR/qualif-indirect-mutation-fail.rs:9:9 | LL | let mut a: (u32, Option) = (0, None); - | ^^^^^ constant functions cannot evaluate destructors + | ^^^^^ the destructor for this type cannot be evaluated in constant functions -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Option` cannot be evaluated at compile-time --> $DIR/qualif-indirect-mutation-fail.rs:15:9 | LL | let mut x = None; - | ^^^^^ constants cannot evaluate destructors + | ^^^^^ the destructor for this type cannot be evaluated in constants -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Option` cannot be evaluated at compile-time --> $DIR/qualif-indirect-mutation-fail.rs:31:9 | LL | let _z = x; - | ^^ constants cannot evaluate destructors + | ^^ the destructor for this type cannot be evaluated in constants -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Option` cannot be evaluated at compile-time --> $DIR/qualif-indirect-mutation-fail.rs:36:9 | LL | let x: Option = None; - | ^ constant functions cannot evaluate destructors + | ^ the destructor for this type cannot be evaluated in constant functions -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Option` cannot be evaluated at compile-time --> $DIR/qualif-indirect-mutation-fail.rs:44:9 | LL | let _y = x; - | ^^ constant functions cannot evaluate destructors + | ^^ the destructor for this type cannot be evaluated in constant functions -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Option` cannot be evaluated at compile-time --> $DIR/qualif-indirect-mutation-fail.rs:52:9 | LL | let mut y: Option = None; - | ^^^^^ constant functions cannot evaluate destructors + | ^^^^^ the destructor for this type cannot be evaluated in constant functions -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Option` cannot be evaluated at compile-time --> $DIR/qualif-indirect-mutation-fail.rs:49:9 | LL | let mut x: Option = None; - | ^^^^^ constant functions cannot evaluate destructors + | ^^^^^ the destructor for this type cannot be evaluated in constant functions -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Option` cannot be evaluated at compile-time --> $DIR/qualif-indirect-mutation-fail.rs:62:9 | LL | let y: Option = None; - | ^ constant functions cannot evaluate destructors + | ^ the destructor for this type cannot be evaluated in constant functions -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Option` cannot be evaluated at compile-time --> $DIR/qualif-indirect-mutation-fail.rs:59:9 | LL | let x: Option = None; - | ^ constant functions cannot evaluate destructors + | ^ the destructor for this type cannot be evaluated in constant functions error: aborting due to 9 previous errors diff --git a/src/test/ui/consts/raw-ptr-const.rs b/src/test/ui/consts/raw-ptr-const.rs index 00fad046b..b9c542d03 100644 --- a/src/test/ui/consts/raw-ptr-const.rs +++ b/src/test/ui/consts/raw-ptr-const.rs @@ -1,5 +1,3 @@ -#![allow(const_err)] // make sure we hit the `delay_span_bug` - // This is a regression test for a `delay_span_bug` during interning when a constant // evaluates to a (non-dangling) raw pointer. For now this errors; potentially it // could also be allowed. diff --git a/src/test/ui/consts/raw-ptr-const.stderr b/src/test/ui/consts/raw-ptr-const.stderr index 0ebe1e95c..f7b53433b 100644 --- a/src/test/ui/consts/raw-ptr-const.stderr +++ b/src/test/ui/consts/raw-ptr-const.stderr @@ -1,5 +1,5 @@ error: untyped pointers are not allowed in constant - --> $DIR/raw-ptr-const.rs:7:1 + --> $DIR/raw-ptr-const.rs:5:1 | LL | const CONST_RAW: *const Vec = &Vec::new() as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/recursive.rs b/src/test/ui/consts/recursive.rs index 664940c52..5d736e31b 100644 --- a/src/test/ui/consts/recursive.rs +++ b/src/test/ui/consts/recursive.rs @@ -2,8 +2,7 @@ const fn f(x: T) { //~ WARN function cannot return without recursing f(x); - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler + //~^ ERROR evaluation of constant value failed } const X: () = f(1); diff --git a/src/test/ui/consts/recursive.stderr b/src/test/ui/consts/recursive.stderr index 647ed1db2..14fa3da7a 100644 --- a/src/test/ui/consts/recursive.stderr +++ b/src/test/ui/consts/recursive.stderr @@ -6,10 +6,10 @@ LL | const fn f(x: T) { LL | f(x); | ---- recursive call site | - = note: `#[warn(unconditional_recursion)]` on by default = help: a `loop` may express intention better if this is on purpose + = note: `#[warn(unconditional_recursion)]` on by default -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/recursive.rs:4:5 | LL | f(x); @@ -18,33 +18,10 @@ LL | f(x); | reached the configured maximum number of stack frames | inside `f::` at $DIR/recursive.rs:4:5 | [... 126 additional calls inside `f::` at $DIR/recursive.rs:4:5 ...] - | inside `X` at $DIR/recursive.rs:9:15 ... LL | const X: () = f(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 + | ---- inside `X` at $DIR/recursive.rs:8:15 error: aborting due to previous error; 1 warning emitted -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/recursive.rs:4:5 - | -LL | f(x); - | ^^^^ - | | - | reached the configured maximum number of stack frames - | inside `f::` at $DIR/recursive.rs:4:5 - | [... 126 additional calls inside `f::` at $DIR/recursive.rs:4:5 ...] - | inside `X` at $DIR/recursive.rs:9:15 -... -LL | const X: () = f(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 - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/refs_check_const_eq-issue-88384.stderr b/src/test/ui/consts/refs_check_const_eq-issue-88384.stderr index 4f2f5e244..3855b5f2a 100644 --- a/src/test/ui/consts/refs_check_const_eq-issue-88384.stderr +++ b/src/test/ui/consts/refs_check_const_eq-issue-88384.stderr @@ -4,8 +4,8 @@ warning: the feature `adt_const_params` is incomplete and may not be safe to use LL | #![feature(adt_const_params)] | ^^^^^^^^^^^^^^^^ | - = note: `#[warn(incomplete_features)]` on by default = note: see issue #95174 for more information + = note: `#[warn(incomplete_features)]` on by default error[E0741]: using function pointers as const generic parameters is forbidden --> $DIR/refs_check_const_eq-issue-88384.rs:10:21 diff --git a/src/test/ui/consts/stable-precise-live-drops-in-libcore.rs b/src/test/ui/consts/stable-precise-live-drops-in-libcore.rs index 2b970390f..7cd3dbec9 100644 --- a/src/test/ui/consts/stable-precise-live-drops-in-libcore.rs +++ b/src/test/ui/consts/stable-precise-live-drops-in-libcore.rs @@ -11,7 +11,7 @@ impl Either { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "foo", since = "1.0.0")] pub const fn unwrap(self) -> T { - //~^ ERROR destructors cannot be evaluated at compile-time + //~^ ERROR destructor of match self { Self::Left(t) => t, Self::Right(t) => t, diff --git a/src/test/ui/consts/stable-precise-live-drops-in-libcore.stderr b/src/test/ui/consts/stable-precise-live-drops-in-libcore.stderr index a3f513541..5f70391ee 100644 --- a/src/test/ui/consts/stable-precise-live-drops-in-libcore.stderr +++ b/src/test/ui/consts/stable-precise-live-drops-in-libcore.stderr @@ -1,8 +1,8 @@ -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Either` cannot be evaluated at compile-time --> $DIR/stable-precise-live-drops-in-libcore.rs:13:25 | LL | pub const fn unwrap(self) -> T { - | ^^^^ constant functions cannot evaluate destructors + | ^^^^ the destructor for this type cannot be evaluated in constant functions ... LL | } | - value is dropped here diff --git a/src/test/ui/consts/trait_specialization.stderr b/src/test/ui/consts/trait_specialization.stderr index e80821cf4..10bebe8eb 100644 --- a/src/test/ui/consts/trait_specialization.stderr +++ b/src/test/ui/consts/trait_specialization.stderr @@ -4,9 +4,9 @@ warning: the feature `specialization` is incomplete and may not be safe to use a LL | #![feature(specialization)] | ^^^^^^^^^^^^^^ | - = note: `#[warn(incomplete_features)]` on by default = note: see issue #31844 for more information = help: consider using `min_specialization` instead, which is more stable and complete + = note: `#[warn(incomplete_features)]` on by default warning: 1 warning emitted diff --git a/src/test/ui/consts/uninhabited-const-issue-61744.rs b/src/test/ui/consts/uninhabited-const-issue-61744.rs index 860628c39..a07c39882 100644 --- a/src/test/ui/consts/uninhabited-const-issue-61744.rs +++ b/src/test/ui/consts/uninhabited-const-issue-61744.rs @@ -1,8 +1,7 @@ // build-fail pub const unsafe fn fake_type() -> T { - hint_unreachable() //~ ERROR any use of this value will cause an error [const_err] - //~| WARN this was previously accepted by the compiler but is being phased out + hint_unreachable() //~ ERROR evaluation of `::CONSTANT` failed } pub const unsafe fn hint_unreachable() -> ! { diff --git a/src/test/ui/consts/uninhabited-const-issue-61744.stderr b/src/test/ui/consts/uninhabited-const-issue-61744.stderr index d31777847..9c7cc8861 100644 --- a/src/test/ui/consts/uninhabited-const-issue-61744.stderr +++ b/src/test/ui/consts/uninhabited-const-issue-61744.stderr @@ -1,4 +1,4 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of `::CONSTANT` failed --> $DIR/uninhabited-const-issue-61744.rs:4:5 | LL | hint_unreachable() @@ -6,143 +6,142 @@ LL | hint_unreachable() | | | reached the configured maximum number of stack frames | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `::CONSTANT` at $DIR/uninhabited-const-issue-61744.rs:13:36 +... +LL | fake_type() + | ----------- + | | + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 ... LL | const CONSTANT: i32 = unsafe { fake_type() }; - | ------------------- - | - = 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 + | ----------- inside `::CONSTANT` at $DIR/uninhabited-const-issue-61744.rs:12:36 error[E0080]: erroneous constant used - --> $DIR/uninhabited-const-issue-61744.rs:19:10 + --> $DIR/uninhabited-const-issue-61744.rs:18:10 | LL | dbg!(i32::CONSTANT); | ^^^^^^^^^^^^^ referenced constant has errors @@ -150,147 +149,3 @@ LL | dbg!(i32::CONSTANT); error: aborting due to 2 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/uninhabited-const-issue-61744.rs:4:5 - | -LL | hint_unreachable() - | ^^^^^^^^^^^^^^^^^^ - | | - | reached the configured maximum number of stack frames - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 - | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `::CONSTANT` at $DIR/uninhabited-const-issue-61744.rs:13:36 -... -LL | const CONSTANT: i32 = unsafe { fake_type() }; - | ------------------- - | - = 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 - diff --git a/src/test/ui/consts/unnormalized-param-env.rs b/src/test/ui/consts/unnormalized-param-env.rs new file mode 100644 index 000000000..a7bbe4db9 --- /dev/null +++ b/src/test/ui/consts/unnormalized-param-env.rs @@ -0,0 +1,31 @@ +// check-pass + +pub trait CSpace { + type Traj; +} + +pub struct Const; + +pub trait Obstacle { + fn trajectory_free(&self, t: &FT) + where + CS::Traj: Sized, + CS: CSpace; +} + +// ----- + +const N: usize = 4; + +struct ObstacleSpace2df32; + +impl Obstacle for ObstacleSpace2df32 { + fn trajectory_free(&self, t: &TF) + where + CS::Traj: Sized, + CS: CSpace, + { + } +} + +fn main() {} diff --git a/src/test/ui/consts/unstable-const-fn-in-libcore.rs b/src/test/ui/consts/unstable-const-fn-in-libcore.rs index 16b36c8d5..ca4ed8f0b 100644 --- a/src/test/ui/consts/unstable-const-fn-in-libcore.rs +++ b/src/test/ui/consts/unstable-const-fn-in-libcore.rs @@ -4,7 +4,7 @@ // gate was not enabled in libcore. #![stable(feature = "core", since = "1.6.0")] -#![feature(staged_api)] +#![feature(staged_api, const_trait_impl)] enum Opt { Some(T), @@ -14,12 +14,12 @@ enum Opt { impl Opt { #[rustc_const_unstable(feature = "foo", issue = "none")] #[stable(feature = "rust1", since = "1.0.0")] - const fn unwrap_or_else T>(self, f: F) -> T { - //~^ ERROR destructors cannot be evaluated at compile-time - //~| ERROR destructors cannot be evaluated at compile-time + const fn unwrap_or_else T>(self, f: F) -> T { + //~^ ERROR destructor of + //~| ERROR destructor of match self { Opt::Some(t) => t, - Opt::None => f(), //~ ERROR E0015 + Opt::None => f(), } } } diff --git a/src/test/ui/consts/unstable-const-fn-in-libcore.stderr b/src/test/ui/consts/unstable-const-fn-in-libcore.stderr index 180f9f10c..e5b00dd07 100644 --- a/src/test/ui/consts/unstable-const-fn-in-libcore.stderr +++ b/src/test/ui/consts/unstable-const-fn-in-libcore.stderr @@ -1,34 +1,21 @@ -error[E0015]: cannot call non-const closure in constant functions - --> $DIR/unstable-const-fn-in-libcore.rs:22:26 +error[E0493]: destructor of `F` cannot be evaluated at compile-time + --> $DIR/unstable-const-fn-in-libcore.rs:17:60 | -LL | Opt::None => f(), - | ^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -help: consider further restricting this bound - | -LL | const fn unwrap_or_else T + ~const std::ops::FnOnce<()>>(self, f: F) -> T { - | +++++++++++++++++++++++++++++ - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/unstable-const-fn-in-libcore.rs:17:53 - | -LL | const fn unwrap_or_else T>(self, f: F) -> T { - | ^ constant functions cannot evaluate destructors +LL | const fn unwrap_or_else T>(self, f: F) -> T { + | ^ the destructor for this type cannot be evaluated in constant functions ... LL | } | - value is dropped here -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/unstable-const-fn-in-libcore.rs:17:47 +error[E0493]: destructor of `Opt` cannot be evaluated at compile-time + --> $DIR/unstable-const-fn-in-libcore.rs:17:54 | -LL | const fn unwrap_or_else T>(self, f: F) -> T { - | ^^^^ constant functions cannot evaluate destructors +LL | const fn unwrap_or_else T>(self, f: F) -> T { + | ^^^^ the destructor for this type cannot be evaluated in constant functions ... LL | } | - value is dropped here -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0015, E0493. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0493`. diff --git a/src/test/ui/consts/write_to_static_via_mut_ref.rs b/src/test/ui/consts/write_to_static_via_mut_ref.rs index 665c305e9..39b830ae4 100644 --- a/src/test/ui/consts/write_to_static_via_mut_ref.rs +++ b/src/test/ui/consts/write_to_static_via_mut_ref.rs @@ -1,5 +1,4 @@ #![feature(const_mut_refs)] -#![allow(const_err)] static OH_NO: &mut i32 = &mut 42; //~ ERROR mutable references are not allowed fn main() { diff --git a/src/test/ui/consts/write_to_static_via_mut_ref.stderr b/src/test/ui/consts/write_to_static_via_mut_ref.stderr index d19e998d6..f64f0db6b 100644 --- a/src/test/ui/consts/write_to_static_via_mut_ref.stderr +++ b/src/test/ui/consts/write_to_static_via_mut_ref.stderr @@ -1,11 +1,11 @@ error[E0764]: mutable references are not allowed in the final value of statics - --> $DIR/write_to_static_via_mut_ref.rs:4:26 + --> $DIR/write_to_static_via_mut_ref.rs:3:26 | LL | static OH_NO: &mut i32 = &mut 42; | ^^^^^^^ error[E0594]: cannot assign to `*OH_NO`, as `OH_NO` is an immutable static item - --> $DIR/write_to_static_via_mut_ref.rs:7:5 + --> $DIR/write_to_static_via_mut_ref.rs:6:5 | LL | *OH_NO = 43; | ^^^^^^^^^^^ cannot assign -- cgit v1.2.3