pub enum ConstantExprKind<'tcx> {
Show 14 variants
Literal(ConstantLiteral),
Adt {
kind: VariantKind,
fields: Vec<ConstantFieldExpr<'tcx>>,
},
Array {
fields: Vec<ConstantExpr<'tcx>>,
},
Repeat {
value: ConstantExpr<'tcx>,
},
Tuple {
fields: Vec<ConstantExpr<'tcx>>,
},
NamedGlobal(ItemRef<'tcx>),
Ptr {
base: ConstantPtrBase<'tcx>,
projections: Vec<(ConstantProjectionElem<'tcx>, Ty<'tcx>)>,
metadata: Option<UnsizingMetadata<'tcx>>,
},
PtrCast(ConstantExpr<'tcx>, Option<UnsizingMetadata<'tcx>>),
ConstRef {
id: ParamConst,
},
FnDef(ItemRef<'tcx>),
FnPtr(FnPtrTarget<'tcx>),
TypeId(Ty<'tcx>),
Memory(Vec<ConstantByte<'tcx>>),
Todo(String),
}Expand description
The subset of expressions that corresponds to constants.
Variants§
Literal(ConstantLiteral)
Adt
Array
Fields
fields: Vec<ConstantExpr<'tcx>>Repeat
Fields
value: ConstantExpr<'tcx>Tuple
Fields
fields: Vec<ConstantExpr<'tcx>>NamedGlobal(ItemRef<'tcx>)
A top-level or associated constant.
Remark: constants can have generic parameters. Example:
struct V<const N: usize, T> {
x: [T; N],
}
impl<const N: usize, T> V<N, T> {
const LEN: usize = N; // This has generics <N, T>
}
impl Foo for Bar {
const C : usize = 32; // <-
}If options.inline_anon_consts is false, this is also used for inline const blocks and
advanced const generics expressions.
Ptr
A reference or raw pointer (as given by the type of this constant) to a place inside a
constant value: projections applied to base, each with the type of the place it
reaches.
Fields
base: ConstantPtrBase<'tcx>projections: Vec<(ConstantProjectionElem<'tcx>, Ty<'tcx>)>metadata: Option<UnsizingMetadata<'tcx>>PtrCast(ConstantExpr<'tcx>, Option<UnsizingMetadata<'tcx>>)
Casts a thin pointer to the type of this constant. If metadata is given, this is an unsizing cast from the pointee of the given pointer.
ConstRef
Fields
id: ParamConstFnDef(ItemRef<'tcx>)
A function definition, corresponding to a particular item. This is a ZST, unlike FnPtr.
FnPtr(FnPtrTarget<'tcx>)
A function pointer. This is an actual pointer to that function.
TypeId(Ty<'tcx>)
The TypeId of this type.
Memory(Vec<ConstantByte<'tcx>>)
A blob of memory containing the byte representation of the value. This can occur when evaluating MIR constants (e.g. unions). Interpreting this back to a structured value is left as an exercice to the consumer.
Todo(String)
Trait Implementations§
Source§impl<'tcx> Clone for ConstantExprKind<'tcx>
impl<'tcx> Clone for ConstantExprKind<'tcx>
Source§fn clone(&self) -> ConstantExprKind<'tcx>
fn clone(&self) -> ConstantExprKind<'tcx>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'tcx> Debug for ConstantExprKind<'tcx>
impl<'tcx> Debug for ConstantExprKind<'tcx>
impl<'tcx> Eq for ConstantExprKind<'tcx>
Source§impl<'tcx> Hash for ConstantExprKind<'tcx>
impl<'tcx> Hash for ConstantExprKind<'tcx>
Source§impl<'tcx> PartialEq for ConstantExprKind<'tcx>
impl<'tcx> PartialEq for ConstantExprKind<'tcx>
impl<'tcx> StructuralPartialEq for ConstantExprKind<'tcx>
Auto Trait Implementations§
impl<'tcx> DynSend for ConstantExprKind<'tcx>
impl<'tcx> DynSync for ConstantExprKind<'tcx>
impl<'tcx> Freeze for ConstantExprKind<'tcx>
impl<'tcx> RefUnwindSafe for ConstantExprKind<'tcx>
impl<'tcx> Send for ConstantExprKind<'tcx>
impl<'tcx> Sync for ConstantExprKind<'tcx>
impl<'tcx> Unpin for ConstantExprKind<'tcx>
impl<'tcx> UnsafeUnpin for ConstantExprKind<'tcx>
impl<'tcx> UnwindSafe for ConstantExprKind<'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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Dedup for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> HashConsable for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more