pub(crate) struct BindingLevel<'tcx> {
pub params: GenericParams,
pub counts_for_de_bruijn: bool,
pub early_region_vars: FxHashMap<EarlyParamRegion, RegionId>,
pub extra_early_region_vars: FxHashMap<PlaceholderRegion<'tcx>, RegionId>,
pub late_named_region_vars: FxHashMap<DefId, RegionId>,
pub late_anon_region_vars: FxHashMap<DefId, Vec<RegionId>>,
pub bound_region_vars: Vec<RegionId>,
pub used_region_names: FxHashSet<Symbol>,
pub type_vars: FxHashMap<u32, Option<TypeVarId>>,
pub const_generic_vars: FxHashMap<u32, ConstGenericVarId>,
pub trait_preds: FxHashMap<GenericPredicateId, (TraitClauseId, usize)>,
pub type_trans_cache: FxHashMap<Ty<'tcx>, Ty>,
}Expand description
A level of binding for type-level variables. Each item has a top-level binding level corresponding to the parameters and clauses to the items. We may then encounter inner binding levels in the following cases:
for<..>binders in predicates;fn<..>function pointer types;dyn Traittypes, represented asdyn<T: Trait>;- types in a trait declaration or implementation block;
- methods in a trait declaration or implementation block.
At each level, we store two things: a GenericParams that contains the parameters bound at
this level, and various maps from the rustc-internal indices to our indices.
Fields§
§params: GenericParamsThe parameters and predicates bound at this level.
counts_for_de_bruijn: boolWhether this binding level exists in the frontend’s De Bruijn indices. dyn Trait introduces an
existential binder in Charon that has no corresponding binder in rustc/frontend.
early_region_vars: FxHashMap<EarlyParamRegion, RegionId>Rust makes the distinction between early and late-bound region parameters. We do not make this distinction, and merge early and late bound regions. For details, see: https://smallcultfollowing.com/babysteps/blog/2013/10/29/intermingled-parameter-lists/ https://smallcultfollowing.com/babysteps/blog/2013/11/04/intermingled-parameter-lists/
The map of early regions bound at this binder.
extra_early_region_vars: FxHashMap<PlaceholderRegion<'tcx>, RegionId>Extra early regions recovered by unerasing some regions that rustc keeps erased in args. Relevant for closures and inline consts. The frontend represents these regions with placeholder regions.
late_named_region_vars: FxHashMap<DefId, RegionId>The map of named ReLateParam regions bound at this binder.
late_anon_region_vars: FxHashMap<DefId, Vec<RegionId>>The map of anon ReLateParam regions bound at this binder, indexed by the scope DefId
and variable index.
bound_region_vars: Vec<RegionId>The map of ReBound regions bound at this binder, indexed by their bound variable index.
used_region_names: FxHashSet<Symbol>RPITIT can cause region names to be reused. To avoid clashes in our output, we rename duplicate names.
type_vars: FxHashMap<u32, Option<TypeVarId>>The map from rust type variable indices to translated type variable indices. None marks
inference-only parameters, which the frontend should normally never give us.
const_generic_vars: FxHashMap<u32, ConstGenericVarId>The map from rust const generic variables to translated const generic variable indices.
trait_preds: FxHashMap<GenericPredicateId, (TraitClauseId, usize)>The map from trait predicates to the translated trait clause indices, and the number of bound higher-kinded regions.
type_trans_cache: FxHashMap<Ty<'tcx>, Ty>Cache the translation of types. This harnesses the deduplication of Ty that the frontend does.
Implementations§
Source§impl<'tcx> BindingLevel<'tcx>
impl<'tcx> BindingLevel<'tcx>
pub(crate) fn new() -> Self
pub(crate) fn new_dyn() -> Self
Sourcepub(crate) fn push_early_region(
&mut self,
region: EarlyParamRegion,
def_id: DefId,
variance: Variance,
mutability: LifetimeMutability,
) -> RegionId
pub(crate) fn push_early_region( &mut self, region: EarlyParamRegion, def_id: DefId, variance: Variance, mutability: LifetimeMutability, ) -> RegionId
Important: we must push all the early-bound regions before pushing any other region.
Sourcepub(crate) fn push_bound_region(
&mut self,
region: BoundRegionKind,
variance: Variance,
late_param_def_id: Option<&DefId>,
) -> RegionId
pub(crate) fn push_bound_region( &mut self, region: BoundRegionKind, variance: Variance, late_param_def_id: Option<&DefId>, ) -> RegionId
Important: we must push all the early-bound regions before pushing any other region.
Sourcepub fn push_unerased_region(&mut self, region: PlaceholderRegion<'tcx>)
pub fn push_unerased_region(&mut self, region: PlaceholderRegion<'tcx>)
Extra lifetimes unerased from the closure arguments. The frontend represents them with placeholder regions; they are parameters of the closure struct.
pub(crate) fn push_type_var( &mut self, rid: u32, name: Symbol, variance: Variance, ) -> TypeVarId
pub(crate) fn push_const_generic_var(&mut self, rid: u32, ty: Ty, name: Symbol)
Trait Implementations§
Source§impl<'tcx> Debug for BindingLevel<'tcx>
impl<'tcx> Debug for BindingLevel<'tcx>
Auto Trait Implementations§
impl<'tcx> !DynSend for BindingLevel<'tcx>
impl<'tcx> !DynSync for BindingLevel<'tcx>
impl<'tcx> Forget for BindingLevel<'tcx>
impl<'tcx> Freeze for BindingLevel<'tcx>
impl<'tcx> Move for BindingLevel<'tcx>
impl<'tcx> RefUnwindSafe for BindingLevel<'tcx>
impl<'tcx> Send for BindingLevel<'tcx>
impl<'tcx> Sync for BindingLevel<'tcx>
impl<'tcx> Unpin for BindingLevel<'tcx>
impl<'tcx> UnsafeUnpin for BindingLevel<'tcx>
impl<'tcx> UnwindSafe for BindingLevel<'tcx>
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
§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> ⓘ
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 more