pub(crate) struct Runtime<'db> {
data: Rc<RuntimeData<'db>>,
}Fields§
§data: Rc<RuntimeData<'db>>Implementations§
Source§impl<'db> Runtime<'db>
impl<'db> Runtime<'db>
pub(crate) fn execute<T, R>( db: &'db dyn Db, span: Span<'db>, message: &'static str, values: &[&dyn Serialize], constrain: impl AsyncFnOnce(&Runtime<'db>) -> T + 'db, cleanup: impl FnOnce(T) -> R + 'db, ) -> R
fn new( db: &'db dyn Db, compiler_location: &'static Location<'static>, span: Span<'db>, message: &'static str, values: &[&dyn Serialize], ) -> Self
fn next_task_id(&self) -> u64
Sourcefn spawn_future(&self, future: impl Future<Output = ()> + 'db)
fn spawn_future(&self, future: impl Future<Output = ()> + 'db)
Spawn a new check-task.
Sourcefn pop_task(&self) -> Option<Arc<CheckTask>>
fn pop_task(&self) -> Option<Arc<CheckTask>>
Pop and return a task that is ready to execute (if any).
Sourcefn mark_complete(&self)
fn mark_complete(&self)
Mark the inference process as complete and wake all tasks.
Sourcepub fn check_complete(&self) -> bool
pub fn check_complete(&self) -> bool
Returns true if we have fully constructed the object IR for a given function.
Once this returns true, no more bounds will be added to inference variables.
Sourcepub fn fresh_inference_var(
&self,
log: &LogHandle<'_>,
data: InferenceVarData<'db>,
) -> InferVarIndex
pub fn fresh_inference_var( &self, log: &LogHandle<'_>, data: InferenceVarData<'db>, ) -> InferVarIndex
Creates a fresh inference variable of the given kind and universe.
Low-level routine not to be directly invoked.
Sourcepub fn loop_on_inference_var<T>(
&self,
infer: InferVarIndex,
compiler_location: &'static Location<'static>,
log: &LogHandle<'db>,
op: impl FnMut(&InferenceVarData<'db>) -> Option<T>,
) -> impl Future<Output = Option<T>>where
T: Serialize,
pub fn loop_on_inference_var<T>(
&self,
infer: InferVarIndex,
compiler_location: &'static Location<'static>,
log: &LogHandle<'db>,
op: impl FnMut(&InferenceVarData<'db>) -> Option<T>,
) -> impl Future<Output = Option<T>>where
T: Serialize,
Returns a future that blocks the current task until op returns Some.
op will be reinvoked each time the state of the inference variable may have changed.
Sourcepub fn perm_infer(&self, infer: InferVarIndex) -> InferVarIndex
pub fn perm_infer(&self, infer: InferVarIndex) -> InferVarIndex
If infer is a type variable, returns the permission variable associated with infer.
If infer is a permission variable, just returns infer.
Sourcepub fn with_inference_var_data<T>(
&self,
infer: InferVarIndex,
op: impl FnOnce(&InferenceVarData<'db>) -> T,
) -> T
pub fn with_inference_var_data<T>( &self, infer: InferVarIndex, op: impl FnOnce(&InferenceVarData<'db>) -> T, ) -> T
Read the current data for the given inference variable.
A lock is held while the read occurs; deadlock will occur if there is an attempt to mutate inference var data during the read.
Sourcepub fn mutate_inference_var_data<T>(
&self,
infer: InferVarIndex,
log: &LogHandle<'_>,
op: impl FnOnce(&mut InferenceVarData<'db>) -> T,
) -> Twhere
T: InferenceVarDataChanged,
pub fn mutate_inference_var_data<T>(
&self,
infer: InferVarIndex,
log: &LogHandle<'_>,
op: impl FnOnce(&mut InferenceVarData<'db>) -> T,
) -> Twhere
T: InferenceVarDataChanged,
Modify the data for the inference variable infer.
If the data actually changes (as indicated by the
return value of op via the InferenceVarDataChanged
trait), then log the result and wake any tasks blocked on
this inference variable.
op should invoke one of the mutation methods on InferenceVarData
and nothing else. A write lock is held during the call so anything
more complex risks deadlock.
Sourcepub fn insert_sub_infer_var_pair(
&self,
lower: InferVarIndex,
upper: InferVarIndex,
log: &LogHandle<'_>,
) -> bool
pub fn insert_sub_infer_var_pair( &self, lower: InferVarIndex, upper: InferVarIndex, log: &LogHandle<'_>, ) -> bool
Record that lower <: upper must hold,
returning true if this is the first time that this has been recorded
or false if it has been recorded before.
fn wake_tasks_monitoring_inference_var(&self, infer: InferVarIndex)
Sourcepub fn spawn<R>(
&self,
env: &Env<'db>,
task_description: TaskDescription<'db>,
check: impl 'db + AsyncFnOnce(&mut Env<'db>) -> R,
)where
R: DeferResult,
pub fn spawn<R>(
&self,
env: &Env<'db>,
task_description: TaskDescription<'db>,
check: impl 'db + AsyncFnOnce(&mut Env<'db>) -> R,
)where
R: DeferResult,
Execute the given future asynchronously from the main execution. It must execute to completion eventually or an error will be reported.
Sourcefn block_on_inference_var(
&self,
compiler_location: &'static Location<'static>,
log: &LogHandle<'db>,
infer: InferVarIndex,
cx: &mut Context<'_>,
)
fn block_on_inference_var( &self, compiler_location: &'static Location<'static>, log: &LogHandle<'db>, infer: InferVarIndex, cx: &mut Context<'_>, )
Block the current task on changes to the given inference variable.
§Panics
If called when Self::check_complete returns true.
fn report_type_annotations_needed(&self, span: Span<'db>) -> Reported
Trait Implementations§
Auto Trait Implementations§
impl<'db> Freeze for Runtime<'db>
impl<'db> !RefUnwindSafe for Runtime<'db>
impl<'db> !Send for Runtime<'db>
impl<'db> !Sync for Runtime<'db>
impl<'db> Unpin for Runtime<'db>
impl<'db> UnsafeUnpin for Runtime<'db>
impl<'db> !UnwindSafe for Runtime<'db>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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