diff options
| author | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2023-02-22 20:51:29 +0000 |
|---|---|---|
| committer | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2023-02-23 18:42:36 +0000 |
| commit | 025d2a147ff3dcde8f00ad5bc43b446837bd0240 (patch) | |
| tree | c762a9797ea8144815ebbf3f722ecd9005c04b43 /compiler/rustc_middle/src/ty/layout.rs | |
| parent | b869e84e581612f4a30a4bca63bd9e90e9a17003 (diff) | |
| download | rust-025d2a147ff3dcde8f00ad5bc43b446837bd0240.tar.gz rust-025d2a147ff3dcde8f00ad5bc43b446837bd0240.zip | |
Unify validity checks into a single query
Previously, there were two queries to check whether a type allows the 0x01 or zeroed bitpattern. I am planning on adding a further initness to check, truly uninit for MaybeUninit, which would make this three queries. This seems overkill for such a small feature, so this PR unifies them into one.
Diffstat (limited to 'compiler/rustc_middle/src/ty/layout.rs')
| -rw-r--r-- | compiler/rustc_middle/src/ty/layout.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 2d92f377041..a6b85b19f01 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -169,6 +169,23 @@ pub const FAT_PTR_EXTRA: usize = 1; /// * Cranelift stores the base-2 log of the lane count in a 4 bit integer. pub const MAX_SIMD_LANES: u64 = 1 << 0xF; +/// Used in `might_permit_raw_init` to indicate the kind of initialisation +/// that is checked to be valid +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable)] +pub enum InitKind { + Zero, + UninitMitigated0x01Fill, +} + +impl fmt::Display for InitKind { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Zero => f.write_str("zeroed"), + Self::UninitMitigated0x01Fill => f.write_str("filled with 0x01"), + } + } +} + #[derive(Copy, Clone, Debug, HashStable, TyEncodable, TyDecodable)] pub enum LayoutError<'tcx> { Unknown(Ty<'tcx>), |
