# 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>

source

#### pub(super) fn new(tcx: TyCtxt<'tcx>, mode: SolverMode) -> SearchGraph<'tcx>

source

#### pub(super) fn solver_mode(&self) -> SolverMode

source

#### pub(super) fn local_overflow_limit(&self) -> usize

source

#### fn on_cache_hit(&mut self, additional_depth: usize, encountered_overflow: bool)

Update the stack and reached depths on cache hits.

source

#### 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.

source

#### 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.

source

#### pub(super) fn is_empty(&self) -> bool

source

#### pub(super) fn current_goal_is_normalizes_to(&self) -> bool

source

#### 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.

source

#### 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.

source

#### 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> Any for T
where T: 'static + ?Sized,

source§

#### fn type_id(&self) -> TypeId

Gets the `TypeId` of `self`. Read more
source§

### impl<T> Borrow<T> for T
where T: ?Sized,

source§

#### fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

### impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

#### fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

### impl<T> From<T> for T

source§

#### fn from(t: T) -> T

Returns the argument unchanged.

source§

### impl<T, U> Into<U> for T
where U: From<T>,

source§

#### fn into(self) -> U

Calls `U::from(self)`.

That is, this conversion is whatever the implementation of `From<T> for U` chooses to do.

source§

### impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

#### type Error = Infallible

The type returned in the event of a conversion error.
source§

#### fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

### impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

#### type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

#### fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

## 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