Struct rustc_trait_selection::solve::search_graph::SearchGraph
source · pub(super) struct SearchGraph<'tcx> {
mode: SolverMode,
local_overflow_limit: usize,
stack: IndexVec<StackDepth, StackEntry<'tcx>>,
stack_entries: FxHashMap<CanonicalInput<'tcx>, StackDepth>,
}
Fields§
§mode: SolverMode
§local_overflow_limit: usize
§stack: IndexVec<StackDepth, StackEntry<'tcx>>
The stack of goals currently being computed.
An element is deeper in the stack if its index is lower.
stack_entries: FxHashMap<CanonicalInput<'tcx>, StackDepth>
Implementations§
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
pub(super) fn local_overflow_limit(&self) -> usize
sourcefn on_cache_hit(&mut self, additional_depth: usize, encountered_overflow: bool)
fn on_cache_hit(&mut self, additional_depth: usize, encountered_overflow: bool)
Update the stack and reached depths on cache hits.
sourcefn pop_stack(&mut self) -> StackEntry<'tcx>
fn pop_stack(&mut self) -> StackEntry<'tcx>
Pops the highest goal from the stack, lazily updating the the next goal in the stack.
Directly popping from the stack instead of using this method would cause us to not track overflow and recursion depth correctly.
sourcepub(super) fn global_cache(
&self,
tcx: TyCtxt<'tcx>
) -> &'tcx EvaluationCache<'tcx>
pub(super) fn global_cache( &self, tcx: TyCtxt<'tcx> ) -> &'tcx EvaluationCache<'tcx>
The trait solver behavior is different for coherence so we use a separate cache. Alternatively we could use a single cache and share it between coherence and ordinary trait solving.
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.
sourcepub(super) fn encountered_overflow(&self) -> bool
pub(super) fn encountered_overflow(&self) -> bool
Fetches whether the current goal encountered overflow.
This should only be used for the check in evaluate_goal
.
sourcepub(super) fn reset_encountered_overflow(
&mut self,
encountered_overflow: bool
) -> bool
pub(super) fn reset_encountered_overflow( &mut self, encountered_overflow: bool ) -> bool
Resets encountered_overflow
of the current goal.
This should only be used for the check in evaluate_goal
.
sourcefn allowed_depth_for_nested(
tcx: TyCtxt<'tcx>,
stack: &IndexVec<StackDepth, StackEntry<'tcx>>
) -> Option<Limit>
fn allowed_depth_for_nested( tcx: TyCtxt<'tcx>, stack: &IndexVec<StackDepth, StackEntry<'tcx>> ) -> Option<Limit>
Returns the remaining depth allowed for nested goals.
This is generally simply one less than the current depth. However, if we encountered overflow, we significantly reduce the remaining depth of all nested goals to prevent hangs in case there is exponential blowup.
sourcepub(super) fn with_new_goal(
&mut self,
tcx: TyCtxt<'tcx>,
input: CanonicalInput<'tcx>,
inspect: &mut ProofTreeBuilder<'tcx>,
prove_goal: impl FnMut(&mut Self, &mut ProofTreeBuilder<'tcx>) -> QueryResult<'tcx>
) -> QueryResult<'tcx>
pub(super) fn with_new_goal( &mut self, tcx: TyCtxt<'tcx>, input: CanonicalInput<'tcx>, inspect: &mut ProofTreeBuilder<'tcx>, prove_goal: impl FnMut(&mut Self, &mut ProofTreeBuilder<'tcx>) -> QueryResult<'tcx> ) -> QueryResult<'tcx>
Probably the most involved method of the whole solver.
Given some goal which is proven via the prove_goal
closure, this
handles caching, overflow, and coinductive cycles.
fn response_no_constraints( tcx: TyCtxt<'tcx>, goal: CanonicalInput<'tcx>, certainty: Certainty ) -> QueryResult<'tcx>
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: 72 bytes