pub struct MirConst {
pub(crate) kind: ConstantKind,
pub(crate) ty: Ty,
pub id: MirConstId,
}
Expand description
Represents a constant in MIR
Fields§
§kind: ConstantKind
The constant kind.
ty: Ty
The constant type.
id: MirConstId
Used for internal tracking of the internal constant.
Implementations§
source§impl MirConst
impl MirConst
sourcepub fn new(kind: ConstantKind, ty: Ty, id: MirConstId) -> MirConst
pub fn new(kind: ConstantKind, ty: Ty, id: MirConstId) -> MirConst
Build a constant. Note that this should only be used by the compiler.
sourcepub fn kind(&self) -> &ConstantKind
pub fn kind(&self) -> &ConstantKind
Retrieve the constant kind.
sourcepub fn eval_target_usize(&self) -> Result<u64, Error>
pub fn eval_target_usize(&self) -> Result<u64, Error>
Try to evaluate to a target usize
.
sourcepub fn try_new_zero_sized(ty: Ty) -> Result<MirConst, Error>
pub fn try_new_zero_sized(ty: Ty) -> Result<MirConst, Error>
Create a constant that represents a new zero-sized constant of type T. Fails if the type is not a ZST or if it doesn’t have a known size.
sourcepub fn from_str(value: &str) -> MirConst
pub fn from_str(value: &str) -> MirConst
Build a new constant that represents the given string.
Note that there is no guarantee today about duplication of the same constant. I.e.: Calling this function multiple times with the same argument may or may not return the same allocation.
Trait Implementations§
source§impl Visitable for MirConst
impl Visitable for MirConst
fn visit<V: Visitor>(&self, visitor: &mut V) -> ControlFlow<V::Break>
fn super_visit<V: Visitor>(&self, visitor: &mut V) -> ControlFlow<V::Break>
impl Eq for MirConst
impl StructuralPartialEq for MirConst
Auto Trait Implementations§
impl Freeze for MirConst
impl RefUnwindSafe for MirConst
impl Send for MirConst
impl Sync for MirConst
impl Unpin for MirConst
impl UnwindSafe for MirConst
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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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: 96 bytes