Struct rustc_middle::ty::Ty

source ·
pub struct Ty<'tcx>(Interned<'tcx, WithCachedTypeInfo<TyKind<'tcx>>>);
Expand description

Use this rather than TyKind, whenever possible.

Tuple Fields§

§0: Interned<'tcx, WithCachedTypeInfo<TyKind<'tcx>>>

Implementations§

source§

impl<'tcx> Ty<'tcx>

source

pub fn sort_string(self, tcx: TyCtxt<'tcx>) -> Cow<'static, str>

source

pub fn prefix_string(self, tcx: TyCtxt<'_>) -> Cow<'static, str>

source§

impl<'tcx> Ty<'tcx>

source

pub fn inhabited_predicate(self, tcx: TyCtxt<'tcx>) -> InhabitedPredicate<'tcx>

source

pub fn is_inhabited_from( self, tcx: TyCtxt<'tcx>, module: DefId, param_env: ParamEnv<'tcx> ) -> bool

Checks whether a type is visibly uninhabited from a particular module.

Example
#![feature(never_type)]
enum Void {}
mod a {
    pub mod b {
        pub struct SecretlyUninhabited {
            _priv: !,
        }
    }
}

mod c {
    use super::Void;
    pub struct AlsoSecretlyUninhabited {
        _priv: Void,
    }
    mod d {
    }
}

struct Foo {
    x: a::b::SecretlyUninhabited,
    y: c::AlsoSecretlyUninhabited,
}

In this code, the type Foo will only be visibly uninhabited inside the modules b, c and d. This effects pattern-matching on Foo or types that contain Foo.

Example
let foo_result: Result<T, Foo> = ... ;
let Ok(t) = foo_result;

This code should only compile in modules where the uninhabitedness of Foo is visible.

source

pub fn is_privately_uninhabited( self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx> ) -> bool

Returns true if the type is uninhabited without regard to visibility

source§

impl<'tcx> Ty<'tcx>

source

pub fn int_size_and_signed(self, tcx: TyCtxt<'tcx>) -> (Size, bool)

source

pub fn numeric_max_val(self, tcx: TyCtxt<'tcx>) -> Option<Const<'tcx>>

Returns the maximum value for the given numeric type (including chars) or returns None if the type is not numeric.

source

pub fn numeric_min_val(self, tcx: TyCtxt<'tcx>) -> Option<Const<'tcx>>

Returns the minimum value for the given numeric type (including chars) or returns None if the type is not numeric.

source

pub fn is_copy_modulo_regions( self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx> ) -> bool

Checks whether values of this type T are moved or copied when referenced – this amounts to a check for whether T: Copy, but note that we don’t consider lifetimes when doing this check. This means that we may generate MIR which does copies even when the type actually doesn’t satisfy the full requirements for the Copy trait (cc #29149) – this winds up being reported as an error during NLL borrow check.

source

pub fn is_sized(self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> bool

Checks whether values of this type T have a size known at compile time (i.e., whether T: Sized). Lifetimes are ignored for the purposes of this check, so it can be an over-approximation in generic contexts, where one can have strange rules like <T as Foo<'static>>::Bar: Sized that actually carry lifetime requirements.

source

pub fn is_freeze(self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> bool

Checks whether values of this type T implement the Freeze trait – frozen types are those that do not contain an UnsafeCell anywhere. This is a language concept used to distinguish “true immutability”, which is relevant to optimization as well as the rules around static values. Note that the Freeze trait is not exposed to end users and is effectively an implementation detail.

source

fn is_trivially_freeze(self) -> bool

Fast path helper for testing if a type is Freeze.

Returning true means the type is known to be Freeze. Returning false means nothing – could be Freeze, might not be.

source

pub fn is_unpin(self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> bool

Checks whether values of this type T implement the Unpin trait.

source

fn is_trivially_unpin(self) -> bool

Fast path helper for testing if a type is Unpin.

Returning true means the type is known to be Unpin. Returning false means nothing – could be Unpin, might not be.

source

pub fn needs_drop(self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> bool

If ty.needs_drop(...) returns true, then ty is definitely non-copy and might have a destructor attached; if it returns false, then ty definitely has no destructor (i.e., no drop glue).

(Note that this implies that if ty has a destructor attached, then needs_drop will definitely return true for ty.)

Note that this method is used to check eligible types in unions.

source

pub fn has_significant_drop( self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx> ) -> bool

Checks if ty has a significant drop.

Note that this method can return false even if ty has a destructor attached; even if that is the case then the adt has been marked with the attribute rustc_insignificant_dtor.

Note that this method is used to check for change in drop order for 2229 drop reorder migration analysis.

source

pub fn is_structural_eq_shallow(self, tcx: TyCtxt<'tcx>) -> bool

Returns true if equality for this type is both reflexive and structural.

Reflexive equality for a type is indicated by an Eq impl for that type.

Primitive types (u32, str) have structural equality by definition. For composite data types, equality for the type as a whole is structural when it is the same as equality between all components (fields, array elements, etc.) of that type. For ADTs, structural equality is indicated by an implementation of PartialStructuralEq and StructuralEq for that type.

This function is “shallow” because it may return true for a composite type whose fields are not StructuralEq. For example, [T; 4] has structural equality regardless of T because equality for arrays is determined by the equality of each array element. If you want to know whether a given call to PartialEq::eq will proceed structurally all the way down, you will need to use a type visitor.

source

pub fn peel_refs(self) -> Ty<'tcx>

Peel off all reference types in this type until there are none left.

This method is idempotent, i.e. ty.peel_refs().peel_refs() == ty.peel_refs().

Examples
  • u8 -> u8
  • &'a mut u8 -> u8
  • &'a &'b u8 -> u8
  • &'a *const &'b u8 -> *const &'b u8
source

pub fn outer_exclusive_binder(self) -> DebruijnIndex

source§

impl<'tcx> Ty<'tcx>

source

pub fn walk(self) -> TypeWalker<'tcx>

Iterator that walks self and any types reachable from self, in depth-first order. Note that just walks the types that appear in self, it does not descend into the fields of structs or variants. For example:

isize => { isize }
Foo<Bar<isize>> => { Foo<Bar<isize>>, Bar<isize>, isize }
[isize] => { [isize], isize }
source§

impl<'tcx> Ty<'tcx>

source

pub fn is_primitive_ty(self) -> bool

Similar to Ty::is_primitive, but also considers inferred numeric values to be primitive.

source

pub fn is_simple_ty(self) -> bool

Whether the type is succinctly representable as a type instead of just referred to with a description in error messages. This is used in the main error message.

source

pub fn is_simple_text(self, tcx: TyCtxt<'tcx>) -> bool

Whether the type is succinctly representable as a type instead of just referred to with a description in error messages. This is used in the primary span label. Beyond what is_simple_ty includes, it also accepts ADTs with no type arguments and references to ADTs with no type arguments.

source§

impl<'tcx> Ty<'tcx>

Constructors for Ty

source

pub fn new(tcx: TyCtxt<'tcx>, st: TyKind<'tcx>) -> Ty<'tcx>

source

pub fn new_infer(tcx: TyCtxt<'tcx>, infer: InferTy) -> Ty<'tcx>

source

pub fn new_var(tcx: TyCtxt<'tcx>, v: TyVid) -> Ty<'tcx>

source

pub fn new_int_var(tcx: TyCtxt<'tcx>, v: IntVid) -> Ty<'tcx>

source

pub fn new_float_var(tcx: TyCtxt<'tcx>, v: FloatVid) -> Ty<'tcx>

source

pub fn new_fresh(tcx: TyCtxt<'tcx>, n: u32) -> Ty<'tcx>

source

pub fn new_fresh_int(tcx: TyCtxt<'tcx>, n: u32) -> Ty<'tcx>

source

pub fn new_fresh_float(tcx: TyCtxt<'tcx>, n: u32) -> Ty<'tcx>

source

pub fn new_param(tcx: TyCtxt<'tcx>, index: u32, name: Symbol) -> Ty<'tcx>

source

pub fn new_bound( tcx: TyCtxt<'tcx>, index: DebruijnIndex, bound_ty: BoundTy ) -> Ty<'tcx>

source

pub fn new_placeholder( tcx: TyCtxt<'tcx>, placeholder: PlaceholderType ) -> Ty<'tcx>

source

pub fn new_alias( tcx: TyCtxt<'tcx>, kind: AliasKind, alias_ty: AliasTy<'tcx> ) -> Ty<'tcx>

source

pub fn new_opaque( tcx: TyCtxt<'tcx>, def_id: DefId, args: GenericArgsRef<'tcx> ) -> Ty<'tcx>

source

pub fn new_error(tcx: TyCtxt<'tcx>, reported: ErrorGuaranteed) -> Ty<'tcx>

Constructs a TyKind::Error type with current ErrorGuaranteed

source

pub fn new_misc_error(tcx: TyCtxt<'tcx>) -> Ty<'tcx>

Constructs a TyKind::Error type and registers a delay_span_bug to ensure it gets used.

source

pub fn new_error_with_message<S: Into<MultiSpan>>( tcx: TyCtxt<'tcx>, span: S, msg: impl Into<String> ) -> Ty<'tcx>

Constructs a TyKind::Error type and registers a delay_span_bug with the given msg to ensure it gets used.

source

pub fn new_int(tcx: TyCtxt<'tcx>, i: IntTy) -> Ty<'tcx>

source

pub fn new_uint(tcx: TyCtxt<'tcx>, ui: UintTy) -> Ty<'tcx>

source

pub fn new_float(tcx: TyCtxt<'tcx>, f: FloatTy) -> Ty<'tcx>

source

pub fn new_ref( tcx: TyCtxt<'tcx>, r: Region<'tcx>, tm: TypeAndMut<'tcx> ) -> Ty<'tcx>

source

pub fn new_mut_ref(tcx: TyCtxt<'tcx>, r: Region<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx>

source

pub fn new_imm_ref(tcx: TyCtxt<'tcx>, r: Region<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx>

source

pub fn new_ptr(tcx: TyCtxt<'tcx>, tm: TypeAndMut<'tcx>) -> Ty<'tcx>

source

pub fn new_mut_ptr(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx>

source

pub fn new_imm_ptr(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx>

source

pub fn new_adt( tcx: TyCtxt<'tcx>, def: AdtDef<'tcx>, args: GenericArgsRef<'tcx> ) -> Ty<'tcx>

source

pub fn new_foreign(tcx: TyCtxt<'tcx>, def_id: DefId) -> Ty<'tcx>

source

pub fn new_array(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, n: u64) -> Ty<'tcx>

source

pub fn new_array_with_const_len( tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, ct: Const<'tcx> ) -> Ty<'tcx>

source

pub fn new_slice(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx>

source

pub fn new_tup(tcx: TyCtxt<'tcx>, ts: &[Ty<'tcx>]) -> Ty<'tcx>

source

pub fn new_tup_from_iter<I, T>(tcx: TyCtxt<'tcx>, iter: I) -> T::Outputwhere I: Iterator<Item = T>, T: CollectAndApply<Ty<'tcx>, Ty<'tcx>>,

source

pub fn new_fn_def( tcx: TyCtxt<'tcx>, def_id: DefId, args: impl IntoIterator<Item: Into<GenericArg<'tcx>>> ) -> Ty<'tcx>

source

pub fn new_fn_ptr(tcx: TyCtxt<'tcx>, fty: PolyFnSig<'tcx>) -> Ty<'tcx>

source

pub fn new_dynamic( tcx: TyCtxt<'tcx>, obj: &'tcx List<PolyExistentialPredicate<'tcx>>, reg: Region<'tcx>, repr: DynKind ) -> Ty<'tcx>

source

pub fn new_projection( tcx: TyCtxt<'tcx>, item_def_id: DefId, args: impl IntoIterator<Item: Into<GenericArg<'tcx>>> ) -> Ty<'tcx>

source

pub fn new_closure( tcx: TyCtxt<'tcx>, def_id: DefId, closure_args: GenericArgsRef<'tcx> ) -> Ty<'tcx>

source

pub fn new_generator( tcx: TyCtxt<'tcx>, def_id: DefId, generator_args: GenericArgsRef<'tcx>, movability: Movability ) -> Ty<'tcx>

source

pub fn new_generator_witness( tcx: TyCtxt<'tcx>, id: DefId, args: GenericArgsRef<'tcx> ) -> Ty<'tcx>

source

pub fn new_unit(tcx: TyCtxt<'tcx>) -> Ty<'tcx>

source

pub fn new_static_str(tcx: TyCtxt<'tcx>) -> Ty<'tcx>

source

pub fn new_diverging_default(tcx: TyCtxt<'tcx>) -> Ty<'tcx>

source

fn new_generic_adt( tcx: TyCtxt<'tcx>, wrapper_def_id: DefId, ty_param: Ty<'tcx> ) -> Ty<'tcx>

source

pub fn new_lang_item( tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, item: LangItem ) -> Option<Ty<'tcx>>

source

pub fn new_diagnostic_item( tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, name: Symbol ) -> Option<Ty<'tcx>>

source

pub fn new_box(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx>

source

pub fn new_maybe_uninit(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx>

source

pub fn new_task_context(tcx: TyCtxt<'tcx>) -> Ty<'tcx>

Creates a &mut Context<'_> Ty with erased lifetimes.

source§

impl<'tcx> Ty<'tcx>

Type utilities

source

pub fn kind(self) -> &'tcx TyKind<'tcx>

source

pub fn flags(self) -> TypeFlags

source

pub fn is_unit(self) -> bool

source

pub fn is_never(self) -> bool

source

pub fn is_primitive(self) -> bool

source

pub fn is_adt(self) -> bool

source

pub fn is_ref(self) -> bool

source

pub fn is_ty_var(self) -> bool

source

pub fn ty_vid(self) -> Option<TyVid>

source

pub fn is_ty_or_numeric_infer(self) -> bool

source

pub fn is_phantom_data(self) -> bool

source

pub fn is_bool(self) -> bool

source

pub fn is_str(self) -> bool

Returns true if this type is a str.

source

pub fn is_param(self, index: u32) -> bool

source

pub fn is_slice(self) -> bool

source

pub fn is_array_slice(self) -> bool

source

pub fn is_array(self) -> bool

source

pub fn is_simd(self) -> bool

source

pub fn sequence_element_type(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx>

source

pub fn simd_size_and_type(self, tcx: TyCtxt<'tcx>) -> (u64, Ty<'tcx>)

source

pub fn is_mutable_ptr(self) -> bool

source

pub fn ref_mutability(self) -> Option<Mutability>

Get the mutability of the reference or None when not a reference

source

pub fn is_unsafe_ptr(self) -> bool

source

pub fn is_any_ptr(self) -> bool

Tests if this is any kind of primitive pointer type (reference, raw pointer, fn pointer).

source

pub fn is_box(self) -> bool

source

pub fn boxed_ty(self) -> Ty<'tcx>

Panics if called on any type other than Box<T>.

source

pub fn is_scalar(self) -> bool

A scalar type is one that denotes an atomic datum, with no sub-components. (A RawPtr is scalar because it represents a non-managed pointer, so its contents are abstract to rustc.)

source

pub fn is_floating_point(self) -> bool

Returns true if this type is a floating point type.

source

pub fn is_trait(self) -> bool

source

pub fn is_dyn_star(self) -> bool

source

pub fn is_enum(self) -> bool

source

pub fn is_union(self) -> bool

source

pub fn is_closure(self) -> bool

source

pub fn is_generator(self) -> bool

source

pub fn is_integral(self) -> bool

source

pub fn is_fresh_ty(self) -> bool

source

pub fn is_fresh(self) -> bool

source

pub fn is_char(self) -> bool

source

pub fn is_numeric(self) -> bool

source

pub fn is_signed(self) -> bool

source

pub fn is_ptr_sized_integral(self) -> bool

source

pub fn has_concrete_skeleton(self) -> bool

source

pub fn contains(self, other: Ty<'tcx>) -> bool

Checks whether a type recursively contains another type

Example: Option<()> contains ()

source

pub fn contains_closure(self) -> bool

Checks whether a type recursively contains any closure

Example: Option<{closure@file.rs:4:20}> returns true

source

pub fn builtin_deref(self, explicit: bool) -> Option<TypeAndMut<'tcx>>

Returns the type and mutability of *ty.

The parameter explicit indicates if this is an explicit dereference. Some types – notably unsafe ptrs – can only be dereferenced explicitly.

source

pub fn builtin_index(self) -> Option<Ty<'tcx>>

Returns the type of ty[i].

source

pub fn fn_sig(self, tcx: TyCtxt<'tcx>) -> PolyFnSig<'tcx>

source

pub fn is_fn(self) -> bool

source

pub fn is_fn_ptr(self) -> bool

source

pub fn is_impl_trait(self) -> bool

source

pub fn ty_adt_def(self) -> Option<AdtDef<'tcx>>

source

pub fn tuple_fields(self) -> &'tcx List<Ty<'tcx>>

Iterates over tuple fields. Panics when called on anything but a tuple.

source

pub fn variant_range(self, tcx: TyCtxt<'tcx>) -> Option<Range<VariantIdx>>

If the type contains variants, returns the valid range of variant indices.

source

pub fn discriminant_for_variant( self, tcx: TyCtxt<'tcx>, variant_index: VariantIdx ) -> Option<Discr<'tcx>>

If the type contains variants, returns the variant for variant_index. Panics if variant_index is out of range.

source

pub fn discriminant_ty(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx>

Returns the type of the discriminant of this type.

source

pub fn ptr_metadata_ty( self, tcx: TyCtxt<'tcx>, normalize: impl FnMut(Ty<'tcx>) -> Ty<'tcx> ) -> (Ty<'tcx>, bool)

Returns the type of metadata for (potentially fat) pointers to this type, and a boolean signifying if this is conditional on this type being Sized.

source

pub fn to_opt_closure_kind(self) -> Option<ClosureKind>

When we create a closure, we record its kind (i.e., what trait it implements) into its ClosureArgs using a type parameter. This is kind of a phantom type, except that the most convenient thing for us to are the integral types. This function converts such a special type into the closure kind. To go the other way, use closure_kind.to_ty(tcx).

Note that during type checking, we use an inference variable to represent the closure kind, because it has not yet been inferred. Once upvar inference (in rustc_hir_analysis/src/check/upvar.rs) is complete, that type variable will be unified.

source

pub fn is_trivially_sized(self, tcx: TyCtxt<'tcx>) -> bool

Fast path helper for testing if a type is Sized.

Returning true means the type is known to be sized. Returning false means nothing – could be sized, might not be.

Note that we could never rely on the fact that a type such as [_] is trivially !Sized because we could be in a type environment with a bound such as [_]: Copy. A function with such a bound obviously never can be called, but that doesn’t mean it shouldn’t typecheck. This is why this method doesn’t return Option<bool>.

source

pub fn is_trivially_pure_clone_copy(self) -> bool

Fast path helper for primitives which are always Copy and which have a side-effect-free Clone impl.

Returning true means the type is known to be pure and Copy+Clone. Returning false means nothing – could be Copy, might not be.

This is mostly useful for optimizations, as there are the types on which we can replace cloning with dereferencing.

source

pub fn primitive_symbol(self) -> Option<Symbol>

If self is a primitive, return its Symbol.

source

pub fn is_c_void(self, tcx: TyCtxt<'_>) -> bool

source

pub fn is_known_rigid(self) -> bool

Returns true when the outermost type cannot be further normalized, resolved, or substituted. This includes all primitive types, but also things like ADTs and trait objects, sice even if their arguments or nested types may be further simplified, the outermost TyKind or type constructor remains the same.

Trait Implementations§

source§

impl<'tcx> Clone for Ty<'tcx>

source§

fn clone(&self) -> Ty<'tcx>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'tcx> Debug for Ty<'tcx>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'tcx> DebugWithInfcx<TyCtxt<'tcx>> for Ty<'tcx>

source§

fn fmt<InfCtx: InferCtxtLike<TyCtxt<'tcx>>>( this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, f: &mut Formatter<'_> ) -> Result

source§

impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<D> for Ty<'tcx>

source§

fn decode(decoder: &mut D) -> Ty<'tcx>

source§

impl<'tcx> Display for Ty<'tcx>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'tcx, E: TyEncoder<I = TyCtxt<'tcx>>> Encodable<E> for Ty<'tcx>

source§

fn encode(&self, e: &mut E)

source§

impl<'tcx, E: TyEncoder<I = TyCtxt<'tcx>>> EncodableWithShorthand<E> for Ty<'tcx>

§

type Variant = TyKind<TyCtxt<'tcx>>

source§

fn variant(&self) -> &Self::Variant

source§

impl<'tcx> EraseType for Ty<'tcx>

§

type Result = [u8; 8]

source§

impl<'tcx> From<Ty<'tcx>> for GenericArg<'tcx>

source§

fn from(ty: Ty<'tcx>) -> GenericArg<'tcx>

Converts to this type from the input type.
source§

impl<'tcx> From<Ty<'tcx>> for Term<'tcx>

source§

fn from(ty: Ty<'tcx>) -> Self

Converts to this type from the input type.
source§

impl<'tcx> Hash for Ty<'tcx>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'tcx, '__ctx> HashStable<StableHashingContext<'__ctx>> for Ty<'tcx>

source§

fn hash_stable( &self, __hcx: &mut StableHashingContext<'__ctx>, __hasher: &mut StableHasher )

source§

impl<'tcx> IntoDiagnosticArg for Ty<'tcx>

source§

impl<'tcx> Key for Ty<'tcx>

§

type CacheSelector = DefaultCacheSelector<Ty<'tcx>>

source§

fn default_span(&self, _: TyCtxt<'_>) -> Span

In the event that a cycle occurs, if no explicit span has been given for a query with key self, what span should we use?
source§

fn ty_adt_id(&self) -> Option<DefId>

source§

fn key_as_def_id(&self) -> Option<DefId>

If the key is a DefId or DefId–equivalent, return that DefId. Otherwise, return None.
source§

impl<'a, 'tcx> Lift<'tcx> for Ty<'a>

§

type Lifted = Ty<'tcx>

source§

fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted>

source§

impl<'tcx> Ord for Ty<'tcx>

source§

fn cmp(&self, other: &Ty<'tcx>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl ParameterizedOverTcx for Ty<'static>

§

type Value<'tcx> = Ty<'tcx>

source§

impl<'tcx> PartialEq<Ty<'tcx>> for Ty<'tcx>

source§

fn eq(&self, other: &Ty<'tcx>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'tcx> PartialOrd<Ty<'tcx>> for Ty<'tcx>

source§

fn partial_cmp(&self, other: &Ty<'tcx>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'tcx, P: Printer<'tcx>> Print<'tcx, P> for Ty<'tcx>

§

type Output = <P as Printer<'tcx>>::Type

§

type Error = <P as Printer<'tcx>>::Error

source§

fn print(&self, cx: P) -> Result<Self::Output, Self::Error>

source§

impl<'tcx> Relate<'tcx> for Ty<'tcx>

source§

fn relate<R: TypeRelation<'tcx>>( relation: &mut R, a: Ty<'tcx>, b: Ty<'tcx> ) -> RelateResult<'tcx, Ty<'tcx>>

source§

impl<'tcx, C> TyAbiInterface<'tcx, C> for Ty<'tcx>where C: HasTyCtxt<'tcx> + HasParamEnv<'tcx>,

source§

fn ty_and_layout_for_variant( this: TyAndLayout<'tcx>, cx: &C, variant_index: VariantIdx ) -> TyAndLayout<'tcx>

source§

fn ty_and_layout_field( this: TyAndLayout<'tcx>, cx: &C, i: usize ) -> TyAndLayout<'tcx>

source§

fn ty_and_layout_pointee_info_at( this: TyAndLayout<'tcx>, cx: &C, offset: Size ) -> Option<PointeeInfo>

source§

fn is_adt(this: TyAndLayout<'tcx>) -> bool

source§

fn is_never(this: TyAndLayout<'tcx>) -> bool

source§

fn is_tuple(this: TyAndLayout<'tcx>) -> bool

source§

fn is_unit(this: TyAndLayout<'tcx>) -> bool

source§

fn is_transparent(this: TyAndLayout<'tcx>) -> bool

source§

impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for Ty<'tcx>

source§

fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>( self, folder: &mut F ) -> Result<Self, F::Error>

The entry point for folding. To fold a value t with a folder f call: t.try_fold_with(f). Read more
source§

fn fold_with<F>(self, folder: &mut F) -> Selfwhere F: TypeFolder<I>,

A convenient alternative to try_fold_with for use with infallible folders. Do not override this method, to ensure coherence with try_fold_with.
source§

impl<'tcx> TypeSuperFoldable<TyCtxt<'tcx>> for Ty<'tcx>

source§

fn try_super_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>( self, folder: &mut F ) -> Result<Self, F::Error>

Provides a default fold for a recursive type of interest. This should only be called within TypeFolder methods, when a non-custom traversal is desired for the value of the type of interest passed to that method. For example, in MyFolder::try_fold_ty(ty), it is valid to call ty.try_super_fold_with(self), but any other folding should be done with xyz.try_fold_with(self).
source§

fn super_fold_with<F>(self, folder: &mut F) -> Selfwhere F: TypeFolder<I>,

A convenient alternative to try_super_fold_with for use with infallible folders. Do not override this method, to ensure coherence with try_super_fold_with.
source§

impl<'tcx> TypeSuperVisitable<TyCtxt<'tcx>> for Ty<'tcx>

source§

fn super_visit_with<V: TypeVisitor<TyCtxt<'tcx>>>( &self, visitor: &mut V ) -> ControlFlow<V::BreakTy>

Provides a default visit for a recursive type of interest. This should only be called within TypeVisitor methods, when a non-custom traversal is desired for the value of the type of interest passed to that method. For example, in MyVisitor::visit_ty(ty), it is valid to call ty.super_visit_with(self), but any other visiting should be done with xyz.visit_with(self).
source§

impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for Ty<'tcx>

source§

fn visit_with<V: TypeVisitor<TyCtxt<'tcx>>>( &self, visitor: &mut V ) -> ControlFlow<V::BreakTy>

The entry point for visiting. To visit a value t with a visitor v call: t.visit_with(v). Read more
source§

impl<'tcx> Value<TyCtxt<'tcx>> for Ty<'_>

source§

fn from_cycle_error( tcx: TyCtxt<'tcx>, _: &[QueryInfo], guar: ErrorGuaranteed ) -> Self

source§

impl<'tcx> Copy for Ty<'tcx>

source§

impl<'tcx> Eq for Ty<'tcx>

source§

impl<'tcx> StructuralEq for Ty<'tcx>

source§

impl<'tcx> StructuralPartialEq for Ty<'tcx>

Auto Trait Implementations§

§

impl<'tcx> !RefUnwindSafe for Ty<'tcx>

§

impl<'tcx> Send for Ty<'tcx>

§

impl<'tcx> Sync for Ty<'tcx>

§

impl<'tcx> Unpin for Ty<'tcx>

§

impl<'tcx> !UnwindSafe for Ty<'tcx>

Blanket Implementations§

source§

impl<T> Aligned for T

source§

const ALIGN: Alignment = _

Alignment of Self.
source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere T: Copy,

source§

fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut T

source§

fn allocate_from_iter<'a>( arena: &'a Arena<'tcx>, iter: impl IntoIterator<Item = T> ) -> &'a mut [T]

source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, R> CollectAndApply<T, R> for T

source§

fn collect_and_apply<I, F>(iter: I, f: F) -> Rwhere I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

§

type Output = R

source§

impl<Tcx, T> DepNodeParams<Tcx> for Twhere Tcx: DepContext, T: for<'a> HashStable<StableHashingContext<'a>> + Debug,

source§

default fn fingerprint_style() -> FingerprintStyle

source§

default fn to_fingerprint(&self, tcx: Tcx) -> Fingerprint

This method turns the parameters of a DepNodeConstructor into an opaque Fingerprint to be used in DepNode. Not all DepNodeParams support being turned into a Fingerprint (they don’t need to if the corresponding DepNode is anonymous).
source§

default fn to_debug_str(&self, _: Tcx) -> String

source§

default fn recover(_: Tcx, _: &DepNode) -> Option<T>

This method tries to recover the query key from the given DepNode, something which is needed when forcing DepNodes during red-green evaluation. The query system will only call this method if fingerprint_style() is not FingerprintStyle::Opaque. It is always valid to return None here, in which case incremental compilation will treat the query as having changed instead of forcing it.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<P> IntoQueryParam<P> for P

source§

impl<'tcx, T> IsSuggestable<'tcx> for Twhere T: TypeVisitable<TyCtxt<'tcx>> + TypeFoldable<TyCtxt<'tcx>>,

source§

fn is_suggestable(self, tcx: TyCtxt<'tcx>, infer_suggestable: bool) -> bool

Whether this makes sense to suggest in a diagnostic. Read more
source§

fn make_suggestable( self, tcx: TyCtxt<'tcx>, infer_suggestable: bool ) -> Option<T>

source§

impl<T> MaybeResult<T> for T

§

type Error = !

source§

fn from(_: Result<T, <T as MaybeResult<T>>::Error>) -> T

source§

fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<'tcx, T> ToPredicate<'tcx, T> for T

source§

fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> T

source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<'tcx, T> TypeVisitableExt<'tcx> for Twhere T: TypeVisitable<TyCtxt<'tcx>>,

source§

fn has_vars_bound_at_or_above(&self, binder: DebruijnIndex) -> bool

Returns true if self has any late-bound regions that are either bound by binder or bound by some binder outside of binder. If binder is ty::INNERMOST, this indicates whether there are any late-bound regions that appear free.
source§

fn has_vars_bound_above(&self, binder: DebruijnIndex) -> bool

Returns true if this type has any regions that escape binder (and hence are not bound by it).
source§

fn has_escaping_bound_vars(&self) -> bool

Return true if this type has regions that are not a part of the type. For example, for<'a> fn(&'a i32) return false, while fn(&'a i32) would return true. The latter can occur when traversing through the former. Read more
source§

fn has_type_flags(&self, flags: TypeFlags) -> bool

source§

fn has_projections(&self) -> bool

source§

fn has_inherent_projections(&self) -> bool

source§

fn has_opaque_types(&self) -> bool

source§

fn has_generators(&self) -> bool

source§

fn references_error(&self) -> bool

source§

fn error_reported(&self) -> Result<(), ErrorGuaranteed>

source§

fn has_non_region_param(&self) -> bool

source§

fn has_infer_regions(&self) -> bool

source§

fn has_infer_types(&self) -> bool

source§

fn has_non_region_infer(&self) -> bool

source§

fn has_infer(&self) -> bool

source§

fn has_placeholders(&self) -> bool

source§

fn has_non_region_placeholders(&self) -> bool

source§

fn has_param(&self) -> bool

source§

fn has_free_regions(&self) -> bool

“Free” regions in this context means that it has any region that is not (a) erased or (b) late-bound.
source§

fn has_erased_regions(&self) -> bool

source§

fn has_erasable_regions(&self) -> bool

True if there are any un-erased free regions.
source§

fn is_global(&self) -> bool

Indicates whether this value references only ‘global’ generic parameters that are the same regardless of what fn we are in. This is used for caching.
source§

fn has_late_bound_regions(&self) -> bool

True if there are any late-bound regions
source§

fn has_non_region_late_bound(&self) -> bool

True if there are any late-bound non-region variables
source§

fn has_late_bound_vars(&self) -> bool

True if there are any late-bound variables
source§

fn still_further_specializable(&self) -> bool

Indicates whether this value still has parameters/placeholders/inference variables which could be replaced later, in a way that would change the results of impl specialization.
source§

impl<Tcx, T> Value<Tcx> for Twhere Tcx: DepContext,

source§

default fn from_cycle_error( tcx: Tcx, cycle: &[QueryInfo], _guar: ErrorGuaranteed ) -> T

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: 8 bytes