pub struct TyBuilder<D> { /* private fields */ }
Expand description
This is a builder for Ty
or anything that needs a Substitution
.
Implementations§
source§impl<D> TyBuilder<D>
impl<D> TyBuilder<D>
pub fn build_into_subst(self) -> Substitution
pub fn push(self, arg: impl CastTo<GenericArg>) -> Self
pub fn remaining(&self) -> usize
pub fn fill_with_bound_vars( self, debruijn: DebruijnIndex, starting_from: usize, ) -> Self
pub fn fill_with_unknown(self) -> Self
pub fn fill(self, filler: impl FnMut(&ParamKind) -> GenericArg) -> Self
source§impl TyBuilder<()>
impl TyBuilder<()>
pub fn unit() -> Ty
pub fn discr_ty() -> Ty
pub fn bool() -> Ty
pub fn usize() -> Ty
pub fn fn_ptr(sig: CallableSig) -> Ty
pub fn builtin(builtin: BuiltinType) -> Ty
pub fn slice(argument: Ty) -> Ty
pub fn placeholder_subst( db: &dyn HirDatabase, def: impl Into<GenericDefId>, ) -> Substitution
pub fn unknown_subst( db: &dyn HirDatabase, def: impl Into<GenericDefId>, ) -> Substitution
pub fn subst_for_def( db: &dyn HirDatabase, def: impl Into<GenericDefId>, parent_subst: Option<Substitution>, ) -> TyBuilder<()>
sourcepub fn subst_for_coroutine(
db: &dyn HirDatabase,
parent: DefWithBodyId,
) -> TyBuilder<()>
pub fn subst_for_coroutine( db: &dyn HirDatabase, parent: DefWithBodyId, ) -> TyBuilder<()>
Creates a TyBuilder
to build Substitution
for a coroutine defined in parent
.
A coroutine’s substitution consists of:
- resume type of coroutine
- yield type of coroutine (
Coroutine::Yield
) - return type of coroutine (
Coroutine::Return
) - generic parameters in scope on
parent
in this order.
This method prepopulates the builder with placeholder substitution of parent
, so you
should only push exactly 3 GenericArg
s before building.
pub fn subst_for_closure( db: &dyn HirDatabase, parent: DefWithBodyId, sig_ty: Ty, ) -> Substitution
pub fn build(self) -> Substitution
source§impl TyBuilder<AdtId>
impl TyBuilder<AdtId>
pub fn adt(db: &dyn HirDatabase, def: AdtId) -> TyBuilder<AdtId>
pub fn fill_with_defaults( self, db: &dyn HirDatabase, fallback: impl FnMut() -> Ty, ) -> Self
pub fn build(self) -> Ty
source§impl TyBuilder<Tuple>
impl TyBuilder<Tuple>
source§impl TyBuilder<TypeAliasId>
impl TyBuilder<TypeAliasId>
pub fn assoc_type_projection( db: &dyn HirDatabase, def: TypeAliasId, parent_subst: Option<Substitution>, ) -> TyBuilder<TypeAliasId>
pub fn build(self) -> ProjectionTy
source§impl TyBuilder<Binders<Ty>>
impl TyBuilder<Binders<Ty>>
pub fn def_ty( db: &dyn HirDatabase, def: TyDefId, parent_subst: Option<Substitution>, ) -> TyBuilder<Binders<Ty>>
pub fn impl_self_ty(db: &dyn HirDatabase, def: ImplId) -> TyBuilder<Binders<Ty>>
Auto Trait Implementations§
impl<D> Freeze for TyBuilder<D>where
D: Freeze,
impl<D> RefUnwindSafe for TyBuilder<D>where
D: RefUnwindSafe,
impl<D> Send for TyBuilder<D>where
D: Send,
impl<D> Sync for TyBuilder<D>where
D: Sync,
impl<D> Unpin for TyBuilder<D>where
D: Unpin,
impl<D> UnwindSafe for TyBuilder<D>where
D: UnwindSafe,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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 more