about summary refs log tree commit diff
path: root/compiler/rustc_interface/src
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2023-02-21 14:19:58 +0530
committerGitHub <noreply@github.com>2023-02-21 14:19:58 +0530
commit4dea3a295f99f166472ddec78ed9d590900436ff (patch)
tree34b05afe9d34eaa2e63798f6a1bd4d3491b2cffc /compiler/rustc_interface/src
parentf715e430aac0de131e2ad21804013ea405722a66 (diff)
parent0610df931449375a80bdd7ae03c2fd3116291c82 (diff)
downloadrust-4dea3a295f99f166472ddec78ed9d590900436ff.tar.gz
rust-4dea3a295f99f166472ddec78ed9d590900436ff.zip
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
Diffstat (limited to 'compiler/rustc_interface/src')
0 files changed, 0 insertions, 0 deletions