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_certain
tries 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::Cell
orstd::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
ty
and returnstrue
if any inner type is an instance of the given adt constructor. - contains_
ty_ adt_ constructor_ opaque - Walks into
ty
and returnstrue
if 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>::Item
forT
Do not invoke without first verifying that the type implementsIterator
- get_
type_ diagnostic_ name - Get the diagnostic name of a type, e.g.
sym::HashMap
. To check if a type implements a trait marked with a diagnostic item useimplements_trait
. - 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
ty
is known to have aiter
oriter_mut
method, returns a symbol representing the type. - has_
non_ owning_ mutable_ access - Check if a Ty<’_> of
Iterator
contains any mutable access to non-owning types by checking if it contains fields of mutable references or pointers, or references/pointers to non-Freeze
types, orPhantomData
types 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_trait
but allows using aParamEnv
different from the lint context. - implements_
trait_ with_ env_ from_ iter - Same as
implements_trait_from_env
but 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_void
types in libc. - is_copy
- Checks if the given type implements copy.
- is_
isize_ or_ usize - Return
true
if the passedtyp
isisize
orusize
. - is_
manually_ drop - Checks if the type is
core::mem::ManuallyDrop<_>
- is_
must_ use_ ty - is_
never_ like - Returns whether
ty
is never-like; i.e.,!
(never) or an enum with zero variants. - is_
non_ aggregate_ primitive_ type - Returns
true
if the given type is a non aggregate primitive (abool
orchar
, any integer or floating-point number type). - is_
recursively_ primitive_ type - Returns
true
if the given type is a primitive (abool
orchar
, any integer or floating-point number type, astr
, or an array, slice, or tuple of those types). - is_
slice_ like - Check if
ty
is slice-like, i.e.,&[T]
,[T; N]
, orVec<T>
. - is_
type_ diagnostic_ item - Checks if the type is equal to a diagnostic item. To check if a type implements a
trait marked with a diagnostic item use
implements_trait
. - is_
type_ lang_ item - Checks if the type is equal to a lang item.
- is_
type_ ref_ to_ diagnostic_ item - Checks if the type is a reference equals to a diagnostic item
- 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
true
ifty
denotes 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
ty
is anOption
and 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
a
andb
are same types having sameConst
generic args, but ignores lifetimes. - should_
call_ clone_ as_ function - Returns true if
ty
is a type on which callingClone
through 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::Ty
to arustc_middle::ty::Ty
. - ty_sig
- If the type is function like, get the signature for it.