rust/tests/ui/consts/const-eval
Dylan DPC 4dea3a295f
Rollup merge of #108000 - y21:no-zero-init-for-uninhabited, r=jackh726
lint: don't suggest MaybeUninit::assume_init for uninhabited types

Creating a zeroed uninhabited type such as `!` or an empty enum with `mem::zeroed()` (or transmuting `()` to `!`) currently triggers this lint:
```rs
warning: the type `!` does not permit zero-initialization
 --> test.rs:5:23
  |
5 |         let _val: ! = mem::zeroed();
  |                       ^^^^^^^^^^^^^
  |                       |
  |                       this code causes undefined behavior when executed
  |                       help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
  |
  = note: the `!` type has no valid value
```
The `MaybeUninit` suggestion in the help message seems confusing/useless for uninhabited types, as such a type cannot be fully initialized in the first place (as the note implies).
This PR limits this help message to inhabited types which can be initialized
2023-02-21 14:19:58 +05:30
..
auxiliary Move /src/test to /tests 2023-01-11 09:32:08 +00:00
heap Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simd Move /src/test to /tests 2023-01-11 09:32:08 +00:00
stable-metric Move const-eval/stable-metric ui tests 2023-01-24 00:01:40 +00:00
assign-to-static-within-other-static.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
assign-to-static-within-other-static.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
conditional_array_execution.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
conditional_array_execution.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_fn_ptr_fail2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_fn_ptr_fail2.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_fn_ptr_fail.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_fn_ptr_fail.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_fn_ptr.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_fn_ptr.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_let.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_let.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_panic_2021.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_panic_2021.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_panic_libcore_bin.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_panic_libcore_bin.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_panic_stability.e2018.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_panic_stability.e2021.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_panic_stability.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_panic_track_caller.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_panic_track_caller.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_panic.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_panic.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_prop_errors.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_raw_ptr_ops2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_raw_ptr_ops2.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_raw_ptr_ops.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_raw_ptr_ops.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_signed_pat.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-intrinsic-promotion.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-intrinsic-promotion.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-overflow2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-overflow2.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-overflow2b.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-overflow2b.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-overflow2c.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-overflow2c.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-overflow-2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-overflow-2.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-overflow-3.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-overflow-3.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-overflow-3b.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-overflow-3b.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-overflow-4.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-overflow-4.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-overflow-4b.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-overflow-4b.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-query-stack.rs Tweak ICE message 2023-02-07 19:17:24 +00:00
const-eval-query-stack.stderr Tweak ICE message 2023-02-07 19:17:24 +00:00
const-eval-span.rs Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
const-eval-span.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
const-pointer-values-in-various-types.64bit.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-pointer-values-in-various-types.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
dangling.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
dangling.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
dont_promote_unstable_const_fn_cross_crate.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
dont_promote_unstable_const_fn_cross_crate.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
dont_promote_unstable_const_fn.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
dont_promote_unstable_const_fn.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
double_check2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
double_check.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
duration_conversion.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
enum_discr.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
erroneous-const2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
erroneous-const2.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
erroneous-const.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
erroneous-const.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
extern_fat_pointer.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
format.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
format.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
generic-slice.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
generic-slice.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ice-generic-assoc-const.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ice-packed.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
index_out_of_bounds_propagated.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
index_out_of_bounds_propagated.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
index_out_of_bounds.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
index_out_of_bounds.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
index-out-of-bounds-never-type.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
index-out-of-bounds-never-type.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
infinite_loop.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
infinite_loop.stderr Bless and update consts tests 2023-01-23 23:56:22 +00:00
issue-43197.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-43197.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-44578.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-44578.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-47971.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-49296.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-49296.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-50706.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-50814-2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-50814-2.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-50814.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-50814.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-51300.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-52475.rs Bless and update consts tests 2023-01-23 23:56:22 +00:00
issue-52475.stderr Bless and update consts tests 2023-01-23 23:56:22 +00:00
issue-53157.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-53401.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-55541.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-64908.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-64970.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-65394.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-65394.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-70723.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-70723.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-70804-fn-subtyping.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-84957-const-str-as-bytes.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-85155.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-85155.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-85907.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-85907.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-91827-extern-types.rs Fix unintentional UB in ui tests 2023-02-15 09:05:05 -05:00
issue-100878.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-104390.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-104390.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
livedrop.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
livedrop.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
match-test-ptr-null.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
match-test-ptr-null.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
mod-static-with-const-fn.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
mod-static-with-const-fn.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
no_lint_for_statically_known_error.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
nrvo.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
panic-assoc-never-type.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
panic-assoc-never-type.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
panic-never-type.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
panic-never-type.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
partial_ptr_overwrite.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
partial_ptr_overwrite.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
promote_mutable_zst_mir_borrowck.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
promote-static.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
promoted_const_fn_fail_deny_const_err.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
promoted_const_fn_fail_deny_const_err.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
promoted_const_fn_fail.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
promoted_const_fn_fail.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
promoted_errors.noopt.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
promoted_errors.opt_with_overflow_checks.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
promoted_errors.opt.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
promoted_errors.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
promoted_raw_ptr_ops.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
promoted_raw_ptr_ops.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
raw-bytes.32bit.stderr basic dyn* support for Miri 2023-02-20 15:08:05 +01:00
raw-bytes.64bit.stderr basic dyn* support for Miri 2023-02-20 15:08:05 +01:00
raw-bytes.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ref_to_int_match.32bit.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ref_to_int_match.64bit.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ref_to_int_match.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
shift_overflow.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
shift_overflow.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simple_with_undef.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
size-of-t.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
size-of-t.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
strlen.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transmute-const-promotion.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transmute-const-promotion.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transmute-const.32bit.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transmute-const.64bit.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transmute-const.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-enum-overwrite.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-enum-overwrite.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-enum.32bit.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-enum.64bit.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-enum.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-incorrect-vtable.32bit.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-incorrect-vtable.64bit.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-incorrect-vtable.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-int-array.32bit.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-int-array.64bit.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-int-array.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-nonnull.chalk.64bit.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-nonnull.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-nonnull.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-ref-ptr.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-ref-ptr.stderr basic dyn* support for Miri 2023-02-20 15:08:05 +01:00
ub-uninhabit.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-uninhabit.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-upvars.32bit.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-upvars.64bit.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-upvars.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-wide-ptr.chalk.64bit.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-wide-ptr.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ub-wide-ptr.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
union_promotion.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
union_promotion.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
union-const-eval-field.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
union-const-eval-field.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
union-ice.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
union-ice.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
union-ub.32bit.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
union-ub.64bit.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
union-ub.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unused-broken-const.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unused-broken-const.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unwind-abort.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unwind-abort.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
valid-const.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
validate_uninhabited_zsts.32bit.stderr lint: don't suggest assume_init for uninhabited types 2023-02-18 19:05:44 +01:00
validate_uninhabited_zsts.64bit.stderr lint: don't suggest assume_init for uninhabited types 2023-02-18 19:05:44 +01:00
validate_uninhabited_zsts.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
write-to-uninhabited-enum-variant.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
zst_operand_eval.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00