diff options
| author | Ralf Jung <post@ralfj.de> | 2024-11-07 21:44:28 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-11-08 07:35:29 +0100 |
| commit | 35a913b968eb9ad3a271f72fcc1bcd168bb572a4 (patch) | |
| tree | 18cbbadae7805bb3ca8e1238c186a0ddf73e88da /compiler/rustc_abi/src | |
| parent | 3d1dba830a564d1118361345d7ada47a05241f45 (diff) | |
| download | rust-35a913b968eb9ad3a271f72fcc1bcd168bb572a4.tar.gz rust-35a913b968eb9ad3a271f72fcc1bcd168bb572a4.zip | |
pointee_info_at: fix logic for recursing into enums
Diffstat (limited to 'compiler/rustc_abi/src')
| -rw-r--r-- | compiler/rustc_abi/src/lib.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index ec758785173..7b6abdf1ea9 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -1743,15 +1743,23 @@ pub enum PointerKind { Box { unpin: bool, global: bool }, } -/// Note that this information is advisory only, and backends are free to ignore it. -/// It can only be used to encode potential optimizations, but no critical information. +/// Encodes extra information we have about a pointer. +/// Note that this information is advisory only, and backends are free to ignore it: +/// if the information is wrong, that can cause UB, but if the information is absent, +/// that must always be okay. #[derive(Copy, Clone, Debug)] pub struct PointeeInfo { - pub size: Size, - pub align: Align, /// If this is `None`, then this is a raw pointer, so size and alignment are not guaranteed to /// be reliable. pub safe: Option<PointerKind>, + /// If `safe` is `Some`, then the pointer is either null or dereferenceable for this many bytes. + /// On a function argument, "dereferenceable" here means "dereferenceable for the entire duration + /// of this function call", i.e. it is UB for the memory that this pointer points to to be freed + /// while this function is still running. + /// The size can be zero if the pointer is not dereferenceable. + pub size: Size, + /// If `safe` is `Some`, then the pointer is aligned as indicated. + pub align: Align, } impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> { |
