pub struct Ty<'gcx>(/* private fields */);Expand description
An interned type.
Implementations§
Source§impl<'gcx> Ty<'gcx>
impl<'gcx> Ty<'gcx>
pub fn new(gcx: Gcx<'gcx>, kind: TyKind<'gcx>) -> Ty<'gcx>
Sourcepub fn display(self, gcx: Gcx<'gcx>) -> impl Display + use<'gcx>
pub fn display(self, gcx: Gcx<'gcx>) -> impl Display + use<'gcx>
Displays the type for human-readable diagnostics.
pub fn with_loc(self, gcx: Gcx<'gcx>, loc: DataLocation) -> Ty<'gcx>
pub fn with_loc_if_ref(self, gcx: Gcx<'gcx>, loc: DataLocation) -> Ty<'gcx>
pub fn with_loc_if_ref_opt( self, gcx: Gcx<'gcx>, loc: Option<DataLocation>, ) -> Ty<'gcx>
Sourcepub fn loc(self) -> Option<DataLocation>
pub fn loc(self) -> Option<DataLocation>
Returns the location of the type if it is a reference.
pub fn as_externally_callable_function( self, in_library: bool, gcx: Gcx<'gcx>, ) -> Ty<'gcx>
pub fn as_attached_function(self, gcx: Gcx<'gcx>) -> Ty<'gcx>
pub fn make_ref(self, gcx: Gcx<'gcx>, loc: DataLocation) -> Ty<'gcx>
pub fn make_type_type(self, gcx: Gcx<'gcx>) -> Ty<'gcx>
pub fn make_meta(self, gcx: Gcx<'gcx>) -> Ty<'gcx>
Sourcepub fn is_ref_at(self, loc: DataLocation) -> bool
pub fn is_ref_at(self, loc: DataLocation) -> bool
Returns true if the type is a reference to the given location.
Sourcepub fn data_stored_in(self, loc: DataLocation) -> bool
pub fn data_stored_in(self, loc: DataLocation) -> bool
Returns true if the type is a reference to the given location.
Sourcepub fn is_value_type(self) -> bool
pub fn is_value_type(self) -> bool
Returns true if the type is a value type.
Reference: https://docs.soliditylang.org/en/latest/types.html#value-types
Sourcepub fn is_reference_type(self) -> bool
pub fn is_reference_type(self) -> bool
Returns true if the type is a reference type.
Sourcepub fn is_recursive(self, gcx: Gcx<'gcx>) -> bool
pub fn is_recursive(self, gcx: Gcx<'gcx>) -> bool
Returns true if the type is recursive.
Sourcepub fn has_mapping(self, gcx: Gcx<'gcx>) -> bool
pub fn has_mapping(self, gcx: Gcx<'gcx>) -> bool
Returns true if this type contains a mapping.
Sourcepub fn contains_library(self, gcx: Gcx<'gcx>) -> bool
pub fn contains_library(self, gcx: Gcx<'gcx>) -> bool
Returns true if this type contains a library contract type.
Sourcepub fn has_internal_function(self) -> bool
pub fn has_internal_function(self) -> bool
Returns true if this type contains a non-public (internal/private) function type.
Sourcepub fn error_reported(self) -> Result<(), ErrorGuaranteed>
pub fn error_reported(self) -> Result<(), ErrorGuaranteed>
Returns Err(guar) if this type contains an error.
Sourcepub fn references_error(self) -> bool
pub fn references_error(self) -> bool
Returns true if this type contains an error.
Sourcepub fn can_be_exported(self, gcx: Gcx<'gcx>) -> bool
pub fn can_be_exported(self, gcx: Gcx<'gcx>) -> bool
Returns true if this type can be part of an externally callable function.
Sourcepub fn parameters(self) -> Option<&'gcx [Ty<'gcx>]>
pub fn parameters(self) -> Option<&'gcx [Ty<'gcx>]>
Returns the parameter types of the type.
Sourcepub fn state_mutability(self) -> Option<StateMutability>
pub fn state_mutability(self) -> Option<StateMutability>
Returns the state mutability of the type.
Sourcepub fn function_id(self) -> Option<FunctionId>
pub fn function_id(self) -> Option<FunctionId>
Returns the function ID if this is a function type with a specific function.
Sourcepub fn item_id(self) -> Option<ItemId>
pub fn item_id(self) -> Option<ItemId>
Returns the HIR item ID associated with this type, if any.
Sourcepub fn item_source(self, gcx: Gcx<'gcx>) -> Option<SourceId>
pub fn item_source(self, gcx: Gcx<'gcx>) -> Option<SourceId>
Returns the source ID where this type’s HIR item is defined.
Sourcepub fn visit<T>(
self,
f: &mut impl FnMut(Ty<'gcx>) -> ControlFlow<T>,
) -> ControlFlow<T>
pub fn visit<T>( self, f: &mut impl FnMut(Ty<'gcx>) -> ControlFlow<T>, ) -> ControlFlow<T>
Visits the type and its subtypes.
Sourcepub fn is_array_like(&self) -> bool
pub fn is_array_like(&self) -> bool
Returns true if the type is an array-like type.
This is either an array or bytes/string.
Sourcepub fn is_sliceable(self) -> bool
pub fn is_sliceable(self) -> bool
Returns true if the type is sliceable.
This is either an array, bytes, string, or slice.
Sourcepub fn is_dynamically_sized(self) -> bool
pub fn is_dynamically_sized(self) -> bool
Returns true if the type is dynamically sized.
pub fn is_dynamically_encoded(self, gcx: Gcx<'gcx>) -> bool
Sourcepub fn is_fixed_bytes(self) -> bool
pub fn is_fixed_bytes(self) -> bool
Returns true if the type is a fixed-size byte array.
Sourcepub fn is_integer(self) -> bool
pub fn is_integer(self) -> bool
Returns true if the type is an integer, including literals.
Sourcepub fn is_signed(self) -> bool
pub fn is_signed(self) -> bool
Returns true if the type is a signed integer, including negative literals.
Sourcepub fn common_type(self, b: Ty<'gcx>, gcx: Gcx<'gcx>) -> Option<Ty<'gcx>>
pub fn common_type(self, b: Ty<'gcx>, gcx: Gcx<'gcx>) -> Option<Ty<'gcx>>
Returns the common type between the two types.
Sourcepub fn convert_implicit_to(self, other: Ty<'gcx>, gcx: Gcx<'gcx>) -> bool
pub fn convert_implicit_to(self, other: Ty<'gcx>, gcx: Gcx<'gcx>) -> bool
Returns true if the type is implicitly convertible to the given type.
Prefer using Ty::try_convert_implicit_to if you need to handle the error case.
Sourcepub fn try_convert_implicit_to(
self,
other: Ty<'gcx>,
gcx: Gcx<'gcx>,
) -> Result<(), TyConvertError>
pub fn try_convert_implicit_to( self, other: Ty<'gcx>, gcx: Gcx<'gcx>, ) -> Result<(), TyConvertError>
Checks if the type is implicitly convertible to the given type.
See: https://docs.soliditylang.org/en/latest/types.html#implicit-conversions
Sourcepub fn convert_explicit_to(self, other: Ty<'gcx>, gcx: Gcx<'gcx>) -> bool
pub fn convert_explicit_to(self, other: Ty<'gcx>, gcx: Gcx<'gcx>) -> bool
Returns true if the type is explicitly convertible to the given type.
Prefer using Ty::try_convert_explicit_to if you need to handle the error case.
Sourcepub fn try_convert_explicit_to(
self,
other: Ty<'gcx>,
gcx: Gcx<'gcx>,
) -> Result<Ty<'gcx>, TyConvertError>
pub fn try_convert_explicit_to( self, other: Ty<'gcx>, gcx: Gcx<'gcx>, ) -> Result<Ty<'gcx>, TyConvertError>
Performs an explicit type conversion, returning the result type.
For most conversions this is other, but for bytes <-> string with unlocated target,
the result type inherits the source’s data location.
See: https://docs.soliditylang.org/en/latest/types.html#explicit-conversions
Trait Implementations§
impl<'gcx> Copy for Ty<'gcx>
impl<'gcx> Eq for Ty<'gcx>
impl<'gcx> StructuralPartialEq for Ty<'gcx>
Auto Trait Implementations§
impl<'gcx> Freeze for Ty<'gcx>
impl<'gcx> RefUnwindSafe for Ty<'gcx>
impl<'gcx> Send for Ty<'gcx>
impl<'gcx> Sync for Ty<'gcx>
impl<'gcx> Unpin for Ty<'gcx>
impl<'gcx> UnsafeUnpin for Ty<'gcx>
impl<'gcx> UnwindSafe for Ty<'gcx>
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§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
fn equivalent(&self, key: &K) -> bool
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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