pub(crate) struct BindingLevel {
pub params: GenericParams,
pub is_item_binder: bool,
pub early_region_vars: BTreeMap<EarlyParamRegion, RegionId>,
pub bound_region_vars: Vec<RegionId>,
pub type_vars_map: HashMap<u32, TypeVarId>,
pub const_generic_vars_map: HashMap<u32, ConstGenericVarId>,
pub type_trans_cache: HashMap<HashByAddr<Arc<TyKind>>, 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 Trait
types, represented asdyn<T: Trait>
(TODO);- types in a trait declaration or implementation block (TODO);
- methods in a trait declaration or implementation block (TODO).
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: GenericParams
The parameters and predicates bound at this level.
is_item_binder: bool
Whether this binder corresponds to an item (method, type) or not (for<..>
predicate, fn
pointer, etc). This indicates whether it corresponds to a rustc ParamEnv
and therefore
whether we should resolve rustc variables there.
early_region_vars: BTreeMap<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 from rust early regions to translated region indices.
bound_region_vars: Vec<RegionId>
The map from rust late/bound regions to translated region indices.
type_vars_map: HashMap<u32, TypeVarId>
The map from rust type variable indices to translated type variable indices.
const_generic_vars_map: HashMap<u32, ConstGenericVarId>
The map from rust const generic variables to translate const generic variable indices.
type_trans_cache: HashMap<HashByAddr<Arc<TyKind>>, Ty>
Cache the translation of types. This harnesses the deduplication of TyKind
that hax does.
Implementations§
Source§impl BindingLevel
impl BindingLevel
pub(crate) fn new(is_item_binder: bool) -> Self
Sourcepub(crate) fn push_early_region(&mut self, region: EarlyParamRegion) -> RegionId
pub(crate) fn push_early_region(&mut self, region: EarlyParamRegion) -> 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) -> RegionId
pub(crate) fn push_bound_region(&mut self, region: BoundRegionKind) -> RegionId
Important: we must push all the early-bound regions before pushing any other region.
pub(crate) fn push_type_var(&mut self, rid: u32, name: String) -> TypeVarId
pub(crate) fn push_const_generic_var( &mut self, rid: u32, ty: LiteralTy, name: String, )
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BindingLevel
impl RefUnwindSafe for BindingLevel
impl Send for BindingLevel
impl Sync for BindingLevel
impl Unpin for BindingLevel
impl UnwindSafe for BindingLevel
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<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
§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