Struct rustc_trait_selection::solve::search_graph::SearchGraph
source · pub(super) struct SearchGraph<'tcx> {
mode: SolverMode,
stack: IndexVec<StackDepth, StackElem<'tcx>>,
overflow_data: OverflowData,
provisional_cache: ProvisionalCache<'tcx>,
}Fields§
§mode: SolverMode§stack: IndexVec<StackDepth, StackElem<'tcx>>The stack of goals currently being computed.
An element is deeper in the stack if its index is lower.
overflow_data: OverflowData§provisional_cache: ProvisionalCache<'tcx>Implementations§
source§impl<'tcx> SearchGraph<'tcx>
impl<'tcx> SearchGraph<'tcx>
pub fn deal_with_overflow( &mut self, tcx: TyCtxt<'tcx>, goal: Canonical<'tcx, impl Sized> ) -> QueryResult<'tcx>
source§impl<'tcx> SearchGraph<'tcx>
impl<'tcx> SearchGraph<'tcx>
pub(super) fn new(tcx: TyCtxt<'tcx>, mode: SolverMode) -> SearchGraph<'tcx>
pub(super) fn solver_mode(&self) -> SolverMode
sourcepub(super) fn should_use_global_cache(&self) -> bool
pub(super) fn should_use_global_cache(&self) -> bool
We do not use the global cache during coherence.
The trait solver behavior is different for coherence so we would have to add the solver mode to the cache key. This is probably not worth it as trait solving during coherence tends to already be incredibly fast.
We could add another global cache for coherence instead, but that’s effort so let’s only do it if necessary.
pub(super) fn is_empty(&self) -> bool
sourcepub(super) fn in_cycle(&self) -> bool
pub(super) fn in_cycle(&self) -> bool
Whether we’re currently in a cycle. This should only be used for debug assertions.
sourcefn try_push_stack(
&mut self,
tcx: TyCtxt<'tcx>,
input: CanonicalInput<'tcx>
) -> Result<(), QueryResult<'tcx>>
fn try_push_stack( &mut self, tcx: TyCtxt<'tcx>, input: CanonicalInput<'tcx> ) -> Result<(), QueryResult<'tcx>>
Tries putting the new goal on the stack, returning an error if it is already cached.
This correctly updates the provisional cache if there is a cycle.
sourcefn try_finalize_goal(
&mut self,
actual_input: CanonicalInput<'tcx>,
response: QueryResult<'tcx>
) -> bool
fn try_finalize_goal( &mut self, actual_input: CanonicalInput<'tcx>, response: QueryResult<'tcx> ) -> bool
We cannot simply store the result of super::EvalCtxt::compute_goal as we have to deal with coinductive cycles.
When we encounter a coinductive cycle, we have to prove the final result of that cycle while we are still computing that result. Because of this we continuously recompute the cycle until the result of the previous iteration is equal to the final result, at which point we are done.
This function returns true if we were able to finalize the goal and false if it has
updated the provisional cache and we have to recompute the current goal.
FIXME: Refer to the rustc-dev-guide entry once it exists.
pub(super) fn with_new_goal( &mut self, tcx: TyCtxt<'tcx>, canonical_input: CanonicalInput<'tcx>, loop_body: impl FnMut(&mut Self) -> QueryResult<'tcx> ) -> QueryResult<'tcx>
Trait Implementations§
source§impl<'tcx> OverflowHandler<'tcx> for SearchGraph<'tcx>
impl<'tcx> OverflowHandler<'tcx> for SearchGraph<'tcx>
fn search_graph(&mut self) -> &mut SearchGraph<'tcx>
fn repeat_while_none<T>( &mut self, on_overflow: impl FnOnce(&mut Self) -> Result<T, NoSolution>, loop_body: impl FnMut(&mut Self) -> Option<Result<T, NoSolution>> ) -> Result<T, NoSolution>
fn with_incremented_depth<T>( &mut self, on_overflow: impl FnOnce(&mut Self) -> T, body: impl FnOnce(&mut Self) -> T ) -> T
Auto Trait Implementations§
impl<'tcx> !RefUnwindSafe for SearchGraph<'tcx>
impl<'tcx> !Send for SearchGraph<'tcx>
impl<'tcx> !Sync for SearchGraph<'tcx>
impl<'tcx> Unpin for SearchGraph<'tcx>
impl<'tcx> !UnwindSafe for SearchGraph<'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
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:112 bytes