#[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 the
TyKind::Infer
variant unusable and GenericArg::Infer
is used instead.
Fields§
§hir_id: HirId
§span: Span
§kind: TyKind<'hir, Unambig>
Implementations§
Source§impl<'hir> Ty<'hir, AmbigArg>
impl<'hir> Ty<'hir, AmbigArg>
Sourcepub fn as_unambig_ty(&self) -> &Ty<'hir>
pub fn as_unambig_ty(&self) -> &Ty<'hir>
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§impl<'hir> Ty<'hir>
impl<'hir> Ty<'hir>
Sourcepub fn try_as_ambig_ty(&self) -> Option<&Ty<'hir, AmbigArg>>
pub fn try_as_ambig_ty(&self) -> Option<&Ty<'hir, AmbigArg>>
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§impl<'hir> Ty<'hir>
impl<'hir> Ty<'hir>
pub fn peel_refs(&self) -> &Self
Sourcepub fn as_generic_param(&self) -> Option<(DefId, Ident)>
pub fn as_generic_param(&self) -> Option<(DefId, Ident)>
Returns true
if param_def_id
matches the bounded_ty
of this predicate.
pub fn find_self_aliases(&self) -> Vec<Span>
Sourcepub fn is_suggestable_infer_ty(&self) -> bool
pub fn is_suggestable_infer_ty(&self) -> bool
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.
Trait Implementations§
Source§impl<'hir, Unambig, __CTX> HashStable<__CTX> for Ty<'hir, Unambig>where
__CTX: HashStableContext,
Unambig: HashStable<__CTX>,
impl<'hir, Unambig, __CTX> HashStable<__CTX> for Ty<'hir, Unambig>where
__CTX: HashStableContext,
Unambig: HashStable<__CTX>,
fn hash_stable(&self, __hcx: &mut __CTX, __hasher: &mut StableHasher)
impl<'hir, Unambig: Copy> Copy for Ty<'hir, Unambig>
Auto Trait Implementations§
impl<'hir, Unambig> DynSend for Ty<'hir, Unambig>where
Unambig: DynSend,
impl<'hir, Unambig> DynSync for Ty<'hir, Unambig>where
Unambig: DynSync,
impl<'hir, Unambig> Freeze for Ty<'hir, Unambig>where
Unambig: Freeze,
impl<'hir, Unambig> RefUnwindSafe for Ty<'hir, Unambig>where
Unambig: RefUnwindSafe,
impl<'hir, Unambig> Send for Ty<'hir, Unambig>where
Unambig: Send,
impl<'hir, Unambig> Sync for Ty<'hir, Unambig>where
Unambig: Sync,
impl<'hir, Unambig> Unpin for Ty<'hir, Unambig>where
Unambig: Unpin,
impl<'hir, Unambig> UnwindSafe for Ty<'hir, Unambig>where
Unambig: UnwindSafe,
Blanket Implementations§
Source§impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
fn allocate_on(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut T
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'tcx mut [T]
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.