Module clippy_utils::ty
source · Expand description
Util methods for rustc_middle::ty
Modules
- 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
Enums
- A signature for a function like type.
Functions
- Gets the struct or enum variant from the given
Res
- Gets an iterator over all predicates which apply to the given item.
- Comes up with an “at least” guesstimate for the type’s size, not taking into account the layout of type parameters.
- Asserts that the given arguments match the generic parameters of the given item.
- Checks whether a type can be partially moved.
- Walks into
ty
and returnstrue
if any inner type is an instance of the given adt constructor. - Walks into
ty
and returnstrue
if any inner type is an instance of the given type, or adt constructor of the same type. - If the expression is function like, get the signature for it.
- Gets the value of the given variant.
- Resolves
<T as Iterator>::Item
forT
Do not invoke without first verifying that the type implementsIterator
- 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
. - This checks whether a given type is known to implement Debug.
- Checks whether this type implements
Drop
. - Returns true if ty has
iter
oriter_mut
methods - Checks whether a type implements a trait. The function returns false in case the type contains an inference variable.
- Same as
implements_trait
but allows using aParamEnv
different from the lint context. - Same as
implements_trait_from_env
but takes the arguments as an iterator. - 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. - Checks if the given type implements copy.
- Check if given type has inner mutability such as
std::cell::Cell
orstd::cell::RefCell
etc. - Return
true
if the passedtyp
isisize
orusize
. - Returns whether
ty
is never-like; i.e.,!
(never) or an enum with zero variants. - Returns
true
if the given type is a non aggregate primitive (abool
orchar
, any integer or floating-point number type). For checking aggregation of primitive types (e.g. tuples and slices of primitive type) seeis_recursively_primitive_type
- Checks if
Ty
is normalizable. This function is useful to avoid crashes onlayout_of
. - 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). - 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
. - Checks if the type is equal to a lang item.
- Checks if the type is a reference equals to a diagnostic item
- Checks if a given type looks safe to be uninitialized.
- A fallback for polymorphic types, which are not supported by
check_validity_requirement
. - Normalizes the named associated type in the given impl or trait impl.
- Makes the projection type for the named associated type in the given impl or trait impl.
- Checks if type is struct, enum or union type with the given def path.
- Checks if the drop order for a type matters. Some std types implement drop solely to deallocate memory. For these types, and composites containing them, changing the drop order won’t result in any observable side effects.
- Peels off all references on the type. Returns the underlying type and the number of references removed.
- Peels off all references on the type. Returns the underlying type, the number of references removed, and whether the pointer is ultimately mutable or not.
- Attempts to read the given constant as though it were an enum value.
- Returns
true
if typesa
andb
are same types having sameConst
generic args, otherwise returnsfalse
- Checks if the type is a type parameter implementing
FnOnce
, but notFnMut
. - If the type is function like, get the signature for it.
- Gets the diagnostic name of the type, if it has one
- Returns
true
if the given type is anunsafe
function. - Returns the base type for HIR references and pointers.
- Returns the base type for references and raw pointers, and count reference depth.