pub(crate) struct BorrowCheckRootCtxt<'tcx> {
pub tcx: TyCtxt<'tcx>,
root_def_id: LocalDefId,
concrete_opaque_types: ConcreteOpaqueTypes<'tcx>,
collect_region_constraints_results: FxIndexMap<LocalDefId, CollectRegionConstraintsResult<'tcx>>,
propagated_borrowck_results: FxHashMap<LocalDefId, PropagatedBorrowCheckResults<'tcx>>,
tainted_by_errors: Option<ErrorGuaranteed>,
pub consumer: Option<BorrowckConsumer<'tcx>>,
}
Expand description
The shared context used by both the root as well as all its nested items.
Fields§
§tcx: TyCtxt<'tcx>
§root_def_id: LocalDefId
§concrete_opaque_types: ConcreteOpaqueTypes<'tcx>
§collect_region_constraints_results: FxIndexMap<LocalDefId, CollectRegionConstraintsResult<'tcx>>
The region constraints computed by borrowck_collect_region_constraints. This uses an FxIndexMap to guarantee that iterating over it visits nested bodies before their parents.
propagated_borrowck_results: FxHashMap<LocalDefId, PropagatedBorrowCheckResults<'tcx>>
§tainted_by_errors: Option<ErrorGuaranteed>
§consumer: Option<BorrowckConsumer<'tcx>>
This should be None
during normal compilation. See crate::consumers
for more
information on how this is used.
Implementations§
Source§impl<'tcx> BorrowCheckRootCtxt<'tcx>
impl<'tcx> BorrowCheckRootCtxt<'tcx>
pub(crate) fn new( tcx: TyCtxt<'tcx>, root_def_id: LocalDefId, consumer: Option<BorrowckConsumer<'tcx>>, ) -> BorrowCheckRootCtxt<'tcx>
pub(crate) fn root_def_id(&self) -> LocalDefId
pub(crate) fn set_tainted_by_errors(&mut self, guar: ErrorGuaranteed)
pub(crate) fn used_mut_upvars( &mut self, nested_body_def_id: LocalDefId, ) -> &SmallVec<[FieldIdx; 8]>
pub(crate) fn finalize( self, ) -> Result<&'tcx ConcreteOpaqueTypes<'tcx>, ErrorGuaranteed>
fn handle_opaque_type_uses(&mut self)
Sourcefn apply_closure_requirements_modulo_opaques(&mut self)
fn apply_closure_requirements_modulo_opaques(&mut self)
Computing defining uses of opaques may depend on the propagated region requirements of nested bodies, while applying defining uses may introduce additional region requirements we need to propagate.
This results in cyclic dependency. To compute the defining uses in parent bodies, we need the closure requirements of its nested bodies, but to check non-defining uses in nested bodies, we may rely on the defining uses in the parent.
We handle this issue by applying closure requirements twice. Once using the region constraints from before we’ve handled opaque types in the nested body
- which is used by the parent to handle its defining uses - and once after.
As a performance optimization, we also eagerly finish borrowck for bodies
which don’t depend on opaque types. In this case they get removed from
collect_region_constraints_results
and the final result gets put into
propagated_borrowck_results
.
fn compute_closure_requirements_modulo_opaques( input: &CollectRegionConstraintsResult<'tcx>, ) -> Option<ClosureRegionRequirements<'tcx>>
fn apply_closure_requirements( input: &mut CollectRegionConstraintsResult<'tcx>, closure_requirements: &Option<ClosureRegionRequirements<'tcx>>, closure_def_id: LocalDefId, args: GenericArgsRef<'tcx>, locations: Locations, )
pub(crate) fn do_mir_borrowck(&mut self)
Auto Trait Implementations§
impl<'tcx> !DynSend for BorrowCheckRootCtxt<'tcx>
impl<'tcx> !DynSync for BorrowCheckRootCtxt<'tcx>
impl<'tcx> Freeze for BorrowCheckRootCtxt<'tcx>
impl<'tcx> !RefUnwindSafe for BorrowCheckRootCtxt<'tcx>
impl<'tcx> !Send for BorrowCheckRootCtxt<'tcx>
impl<'tcx> !Sync for BorrowCheckRootCtxt<'tcx>
impl<'tcx> Unpin for BorrowCheckRootCtxt<'tcx>
impl<'tcx> !UnwindSafe for BorrowCheckRootCtxt<'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
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
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<P> IntoQueryParam<P> for P
impl<P> IntoQueryParam<P> for P
fn into_query_param(self) -> P
Source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
Source§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
Source§impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> 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<T> ErasedDestructor for Twhere
T: 'static,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 200 bytes