Ty in rustc_hir::hir - Rust (original) (raw)


#[repr(C)]

pub struct Ty<'hir, Unambig = ()> {
    pub hir_id: HirId,
    pub span: Span,
    pub kind: TyKind<'hir, Unambig>,
}

Expand description

Represents a type in the HIR.

The Unambig generic parameter represents whether the position this type is from is unambiguously a type or ambiguous as to whether it is a type or a const. When in an ambiguous context the parameter is instantiated with an uninhabited type making theTyKind::Infer variant unusable and GenericArg::Infer is used instead.

Source§

Source

Converts a Ty in an ambiguous position to one in an unambiguous position.

Functions accepting an unambiguous types may expect the TyKind::Infer variant to be used. Care should be taken to separately handle infer types when calling this function as it cannot be handled by downstream code making use of the returned ty.

In practice this may mean overriding the Visitor::visit_infer method on hir visitors, or specifically matching on GenericArg::Infer when handling generic arguments.

Source§

Source

Converts a Ty in an unambigous position to one in an ambiguous position. This is fallible as the TyKind::Infer variant is not present in ambiguous positions.

Functions accepting ambiguous types will not handle the TyKind::Infer variant, if infer types are relevant to you then care should be taken to handle them separately.

Source§

Source

Source§

Source

Source

Returns true if param_def_id matches the bounded_ty of this predicate.

Source

Source

Whether ty is a type with _ placeholders that can be inferred. Used in diagnostics only to use inference to provide suggestions for the appropriate type if possible.

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.