pub type Const<'tcx> = Const<TyCtxt<'tcx>>;Aliased Type§
pub struct Const<'tcx>(pub Interned<'tcx, WithCachedTypeInfo<ConstKind<TyCtxt<'tcx>>>>);Tuple Fields§
§0: Interned<'tcx, WithCachedTypeInfo<ConstKind<TyCtxt<'tcx>>>>Trait Implementations§
Source§impl<'tcx> ConstExt<'tcx> for Const<'tcx>
impl<'tcx> ConstExt<'tcx> for Const<'tcx>
Source§fn from_bits(
tcx: TyCtxt<'tcx>,
bits: u128,
typing_env: TypingEnv<'tcx>,
ty: Ty<'tcx>,
) -> Self
fn from_bits( tcx: TyCtxt<'tcx>, bits: u128, typing_env: TypingEnv<'tcx>, ty: Ty<'tcx>, ) -> Self
Creates a constant with the given integer value and interns it.
Source§fn zero_sized(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Self
fn zero_sized(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Self
Creates an interned zst constant.
Source§fn from_target_usize(tcx: TyCtxt<'tcx>, n: u64) -> Self
fn from_target_usize(tcx: TyCtxt<'tcx>, n: u64) -> Self
Creates an interned usize constant.
Source§fn try_to_value(self) -> Option<Value<'tcx>>
fn try_to_value(self) -> Option<Value<'tcx>>
Attempts to convert to a value.
Note that this does not normalize the constant.
Source§fn to_leaf(self) -> ScalarInt
fn to_leaf(self) -> ScalarInt
Converts to a ValTreeKind::Leaf value, panic’ing
if this constant is some other kind.
Note that this does not normalize the constant.
Source§fn to_branch(self) -> &'tcx [Const<'tcx>] ⓘ
fn to_branch(self) -> &'tcx [Const<'tcx>] ⓘ
Converts to a ValTreeKind::Branch value, panic’ing
if this constant is some other kind.
Note that this does not normalize the constant.
Source§fn try_to_leaf(self) -> Option<ScalarInt>
fn try_to_leaf(self) -> Option<ScalarInt>
Attempts to convert to a ValTreeKind::Leaf value.
Note that this does not normalize the constant.
Source§fn try_to_scalar(self) -> Option<Scalar>
fn try_to_scalar(self) -> Option<Scalar>
Attempts to convert to a ValTreeKind::Leaf value.
Note that this does not normalize the constant.
Source§fn try_to_branch(self) -> Option<&'tcx [Const<'tcx>]>
fn try_to_branch(self) -> Option<&'tcx [Const<'tcx>]>
Attempts to convert to a ValTreeKind::Branch value.
Note that this does not normalize the constant.
Source§fn try_to_target_usize(self, tcx: TyCtxt<'tcx>) -> Option<u64>
fn try_to_target_usize(self, tcx: TyCtxt<'tcx>) -> Option<u64>
Convenience method to extract the value of a usize constant, useful to get the length of an array type.
Note that this does not evaluate the constant.
Source§fn walk(self) -> TypeWalker<TyCtxt<'tcx>> ⓘ
fn walk(self) -> TypeWalker<TyCtxt<'tcx>> ⓘ
Iterator that walks self and any types reachable from
self, in depth-first order. Note that just walks the types
that appear in self, it does not descend into the fields of
structs or variants. For example:
isize => { isize }
Foo<Bar<isize>> => { Foo<Bar<isize>>, Bar<isize>, isize }
[isize] => { [isize], isize }fn new_value( tcx: TyCtxt<'tcx>, valtree: ValTree<'tcx>, ty: Ty<'tcx>, ) -> Const<'tcx>
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: 8 bytes