rust/compiler/rustc_lint/src
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
..
nonstandard_style mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
array_into_iter.rs refactor: cleanup 2023-01-09 18:57:02 -05:00
builtin.rs lint: don't suggest assume_init for uninhabited types 2023-02-18 19:05:44 +01:00
context.rs Make public API, docs algorithm-agnostic 2023-02-19 04:11:10 +00:00
deref_into_dyn_supertrait.rs Don't eagerly convert principal to string 2023-02-17 14:44:58 +00:00
early.rs fix issues in unused lint 2023-01-14 17:11:04 +08:00
enum_intrinsics_non_enums.rs refactor: cleanup 2023-01-09 18:57:02 -05:00
errors.rs refactor: cleanup 2023-01-09 18:57:02 -05:00
expect.rs Auto merge of #106776 - oli-obk:om_nom_nom_nom_nom, r=cjgillot 2023-01-13 13:57:21 +00:00
for_loops_over_fallibles.rs if $c:expr { Some($r:expr) } else { None } =>> $c.then(|| $r) 2023-02-16 15:26:00 +00:00
hidden_unicode_codepoints.rs migrate: hidden_unicode_codepoints.rs 2023-01-09 17:07:25 -05:00
internal.rs remove bound_type_of query; make type_of return EarlyBinder; change type_of in metadata 2023-02-16 17:05:56 -07:00
late.rs Remove HirId -> LocalDefId map from HIR. 2023-01-28 09:55:26 +00:00
let_underscore.rs refactor: cleanup 2023-01-09 18:57:02 -05:00
levels.rs Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
lib.rs make unaligned_reference a hard error 2023-01-31 20:28:11 +01:00
lints.rs lint: don't suggest assume_init for uninhabited types 2023-02-18 19:05:44 +01:00
methods.rs refactor: cleanup 2023-01-09 18:57:02 -05:00
multiple_supertrait_upcastable.rs Reintroduce multiple_supertrait_upcastable lint 2023-01-28 15:08:07 +00:00
non_ascii_idents.rs refactor: cleanup 2023-01-09 18:57:02 -05:00
non_fmt_panic.rs Use is_str instead of string kind comparison 2023-02-13 19:06:22 +00:00
nonstandard_style.rs Remove HirId -> LocalDefId map from HIR. 2023-01-28 09:55:26 +00:00
noop_method_call.rs refactor: cleanup 2023-01-09 18:57:02 -05:00
opaque_hidden_inferred_bound.rs Ensure no one constructs AliasTys themselves 2022-12-14 15:36:39 +00:00
pass_by_value.rs remove bound_type_of query; make type_of return EarlyBinder; change type_of in metadata 2023-02-16 17:05:56 -07:00
passes.rs Take a LocalDefId in hir::Visitor::visit_fn. 2023-01-28 09:51:50 +00:00
redundant_semicolon.rs refactor: cleanup 2023-01-09 18:57:02 -05:00
tests.rs Update to last upstream version 2021-07-08 17:14:28 +02:00
traits.rs refactor: cleanup 2023-01-09 18:57:02 -05:00
types.rs remove bound_type_of query; make type_of return EarlyBinder; change type_of in metadata 2023-02-16 17:05:56 -07:00
unused.rs s/eval_usize/eval_target_usize/ for clarity 2023-02-14 08:51:19 +00:00