Expand description
Util methods for rustc_middle::ty
Modules§
- type_
certainty 🔒 - A heuristic to tell whether an expression’s type can be determined purely from its
subexpressions, and the arguments and locals they use. Put another way,
expr_type_is_certaintries to tell whether an expression’s type can be determined without appeal to the surrounding context.
Structs§
- AdtVariant
Info - Interior
Mut - Helper to check if given type has inner mutability such as
std::cell::Cellorstd::cell::RefCell.
Enums§
Functions§
- adjust_
derefs_ manually_ drop - Checks if the adjustments contain a mutable dereference of a
ManuallyDrop<_>. - adt_
and_ variant_ of_ res - Gets the struct or enum variant from the given
Res - all_
predicates_ of - Gets an iterator over all predicates which apply to the given item.
- approx_
ty_ size - Comes up with an “at least” guesstimate for the type’s size, not taking into account the layout of type parameters.
- assert_
generic_ 🔒args_ match - Asserts that the given arguments match the generic parameters of the given item.
- can_
partially_ move_ ty - Checks whether a type can be partially moved.
- contains_
adt_ constructor - Walks into
tyand returnstrueif any inner type is an instance of the given adt constructor. - contains_
ty_ adt_ constructor_ opaque - Walks into
tyand returnstrueif any inner type is an instance of the given type, or adt constructor of the same type. - deref_
chain - Returns the deref chain of a type, starting with the type itself.
- expr_
sig - If the expression is function like, get the signature for it.
- expr_
type_ is_ certain - for_
each_ top_ level_ late_ bound_ region - get_
adt_ inherent_ method - Checks if a Ty<’_> has some inherent method Symbol.
- get_
discriminant_ value - Gets the value of the given variant.
- get_
field_ by_ name - Gets the type of a field by name.
- get_
field_ idx_ by_ name - get_
iterator_ item_ ty - Resolves
<T as Iterator>::ItemforTDo not invoke without first verifying that the type implementsIterator - has_
debug_ impl - This checks whether a given type is known to implement Debug.
- has_
drop - Checks whether this type implements
Drop. - has_
iter_ method - If
tyis known to have aiteroriter_mutmethod, returns a symbol representing the type. - has_
non_ owning_ mutable_ access - Check if a Ty<’_> of
Iteratorcontains any mutable access to non-owning types by checking if it contains fields of mutable references or pointers, or references/pointers to non-Freezetypes, orPhantomDatatypes containing any of the previous. This can be used to check whether skipping iterating over an iterator will change its behavior. - implements_
trait - Checks whether a type implements a trait. The function returns false in case the type contains an inference variable.
- implements_
trait_ with_ env - Same as
implements_traitbut allows using aParamEnvdifferent from the lint context. - implements_
trait_ with_ env_ from_ iter - Same as
implements_trait_from_envbut takes the arguments as an iterator. - is_
c_ void - Check if the given type is either
core::ffi::c_void,std::os::raw::c_void, or one of the platform specificlibc::<platform>::c_voidtypes in libc. - is_copy
- Checks if the given type implements copy.
- is_
isize_ or_ usize - Return
trueif the passedtypisisizeorusize. - is_
manually_ drop - Checks if the type is
core::mem::ManuallyDrop<_> - is_
must_ use_ ty - is_
never_ like - Returns whether
tyis never-like; i.e.,!(never) or an enum with zero variants. - is_
non_ aggregate_ primitive_ type - Returns
trueif the given type is a non aggregate primitive (aboolorchar, any integer or floating-point number type). - is_
recursively_ primitive_ type - Returns
trueif the given type is a primitive (aboolorchar, any integer or floating-point number type, astr, or an array, slice, or tuple of those types). - is_
slice_ like - Check if
tyis slice-like, i.e.,&[T],[T; N], orVec<T>. - is_
uninit_ value_ valid_ for_ ty - Checks if a given type looks safe to be uninitialized.
- is_
uninit_ 🔒value_ valid_ for_ ty_ fallback - A fallback for polymorphic types, which are not supported by
check_validity_requirement. - is_
unsafe_ fn - Returns
trueiftydenotes anunsafe fn. - make_
normalized_ projection - Normalizes the named associated type in the given impl or trait impl.
- make_
normalized_ projection_ with_ regions - make_
projection - Makes the projection type for the named associated type in the given impl or trait impl.
- needs_
ordered_ drop - Checks if the drop order for a type matters.
- normalize_
with_ regions - option_
arg_ ty - Check if
tyis anOptionand return its argument type if it is. - peel_
and_ count_ ty_ refs - Peels off all references on the type. Returns the underlying type, the number of references removed, and, if there were any such references, whether the pointer is ultimately mutable or not.
- read_
explicit_ enum_ value - Attempts to read the given constant as though it were an enum value.
- same_
type_ modulo_ regions - Checks whether
aandbare same types having sameConstgeneric args, but ignores lifetimes. - should_
call_ clone_ as_ function - Returns true if
tyis a type on which callingClonethrough a function instead of as a method, such asArc::clone()is considered idiomatic. - sig_
for_ 🔒projection - sig_
from_ 🔒bounds - ty_
from_ hir_ ty - Lower a
hir::Tyto arustc_middle::ty::Ty. - ty_sig
- If the type is function like, get the signature for it.