Type Alias rustc_middle::query::queries::valtree_to_const_val::ProvidedValue
source · pub type ProvidedValue<'tcx> = ConstValue<'tcx>;
Expand description
This type alias specifies the type returned from query providers and the type
used for decoding. For regular queries this is the declared returned type V
,
but arena_cache
will use <V as Deref>::Target
instead.
Aliased Type§
enum ProvidedValue<'tcx> {
Scalar(Scalar),
ZeroSized,
Slice {
data: ConstAllocation<'tcx>,
meta: u64,
},
Indirect {
alloc_id: AllocId,
offset: Size,
},
}
Variants§
Scalar(Scalar)
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 references to unsized types with slice tail.
This is worth an optimized representation since Rust has literals of type &str
and
&[u8]
. Not having to indirect those through an AllocId
(or two, if we used Indirect
)
has shown measurable performance improvements on stress tests. We then reuse this
optimization for slice-tail types more generally during valtree-to-constval conversion.
Fields
data: ConstAllocation<'tcx>
The allocation storing the slice contents. This always points to the beginning of the allocation.
Indirect
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.
Fields
alloc_id: AllocId
The 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
.
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: 24 bytes
Size for each variant:
Scalar
: 24 bytesZeroSized
: 0 bytesSlice
: 24 bytesIndirect
: 24 bytes