Enum miri::ConstValue
source · pub enum ConstValue<'tcx> {
Scalar(Scalar<AllocId>),
ZeroSized,
Slice {
data: ConstAllocation<'tcx>,
start: usize,
end: usize,
},
Indirect {
alloc_id: AllocId,
offset: Size,
},
}Expand description
Represents a constant value in Rust. Scalar and Slice are optimizations for
array length computations, enum discriminants and the pattern matching logic.
Variants§
Scalar(Scalar<AllocId>)
Used for types with layout::abi::Scalar ABI.
Not using the enum Value to encode that this must not be Uninit.
ZeroSized
Only for ZSTs.
Slice
Used for &[u8] and &str.
This is worth an optimized representation since Rust has literals of these types.
Not having to indirect those through an AllocId (or two, if we used Indirect) has shown
measurable performance improvements on stress tests.
Indirect
Fields
alloc_id: AllocIdThe backing memory of the value. May contain more memory than needed for just the value if this points into some other larger ConstValue.
We use an AllocId here instead of a ConstAllocation<'tcx> to make sure that when a
raw constant (which is basically just an AllocId) is turned into a ConstValue and
back, we can preserve the original AllocId.
A value not representable by the other variants; needs to be stored in-memory.
Must not be used for scalars or ZST, but having &str or other slices in this variant is fine.
Auto Trait Implementations§
impl<'tcx> RefUnwindSafe for ConstValue<'tcx>
impl<'tcx> Send for ConstValue<'tcx>
impl<'tcx> Sync for ConstValue<'tcx>
impl<'tcx> Unpin for ConstValue<'tcx>
impl<'tcx> UnwindSafe for ConstValue<'tcx>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size:32 bytes
Size for each variant:
Scalar: 24 bytesZeroSized: 0 bytesSlice: 24 bytesIndirect: 16 bytes