Struct rustc::ty::subst::SubstFolder [−][src]
struct SubstFolder<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { tcx: TyCtxt<'a, 'gcx, 'tcx>, substs: &'a [Kind<'tcx>], span: Option<Span>, root_ty: Option<Ty<'tcx>>, ty_stack_depth: usize, region_binders_passed: u32, }
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Fields
tcx: TyCtxt<'a, 'gcx, 'tcx>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
substs: &'a [Kind<'tcx>]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
span: Option<Span>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
root_ty: Option<Ty<'tcx>>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
ty_stack_depth: usize
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
region_binders_passed: u32
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Methods
impl<'a, 'gcx, 'tcx> SubstFolder<'a, 'gcx, 'tcx>
[src]
impl<'a, 'gcx, 'tcx> SubstFolder<'a, 'gcx, 'tcx>
fn ty_for_param(&self, p: ParamTy, source_ty: Ty<'tcx>) -> Ty<'tcx>
[src]
fn ty_for_param(&self, p: ParamTy, source_ty: Ty<'tcx>) -> Ty<'tcx>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn shift_regions_through_binders(&self, ty: Ty<'tcx>) -> Ty<'tcx>
[src]
fn shift_regions_through_binders(&self, ty: Ty<'tcx>) -> Ty<'tcx>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
It is sometimes necessary to adjust the debruijn indices during substitution. This occurs when we are substituting a type with escaping regions into a context where we have passed through region binders. That's quite a mouthful. Let's see an example:
type Func<A> = fn(A); type MetaFunc = for<'a> fn(Func<&'a int>)
The type MetaFunc
, when fully expanded, will be
for<'a> fn(fn(&'a int)) ^~ ^~ ^~~ | | | | | DebruijnIndex of 2 Binders
Here the 'a
lifetime is bound in the outer function, but appears as an argument of the
inner one. Therefore, that appearance will have a DebruijnIndex of 2, because we must skip
over the inner binder (remember that we count Debruijn indices from 1). However, in the
definition of MetaFunc
, the binder is not visible, so the type &'a int
will have a
debruijn index of 1. It's only during the substitution that we can see we must increase the
depth by 1 to account for the binder that we passed through.
As a second example, consider this twist:
type FuncTuple<A> = (A,fn(A)); type MetaFuncTuple = for<'a> fn(FuncTuple<&'a int>)
Here the final type will be:
for<'a> fn((&'a int, fn(&'a int))) ^~~ ^~~ | | DebruijnIndex of 1 | DebruijnIndex of 2
As indicated in the diagram, here the same type &'a int
is substituted once, but in the
first case we do not increase the Debruijn index and in the second case we do. The reason
is that only in the second case have we passed through a fn binder.
fn shift_region_through_binders(&self, region: Region<'tcx>) -> Region<'tcx>
[src]
fn shift_region_through_binders(&self, region: Region<'tcx>) -> Region<'tcx>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Trait Implementations
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for SubstFolder<'a, 'gcx, 'tcx>
[src]
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for SubstFolder<'a, 'gcx, 'tcx>
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx>
[src]
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> Binder<T>
[src]
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> Binder<T>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn fold_region(&mut self, r: Region<'tcx>) -> Region<'tcx>
[src]
fn fold_region(&mut self, r: Region<'tcx>) -> Region<'tcx>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx>
[src]
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn fold_const(&mut self, c: &'tcx Const<'tcx>) -> &'tcx Const<'tcx>
[src]
fn fold_const(&mut self, c: &'tcx Const<'tcx>) -> &'tcx Const<'tcx>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Auto Trait Implementations
impl<'a, 'gcx, 'tcx> !Send for SubstFolder<'a, 'gcx, 'tcx>
impl<'a, 'gcx, 'tcx> !Send for SubstFolder<'a, 'gcx, 'tcx>
impl<'a, 'gcx, 'tcx> !Sync for SubstFolder<'a, 'gcx, 'tcx>
impl<'a, 'gcx, 'tcx> !Sync for SubstFolder<'a, 'gcx, 'tcx>