[][src]Trait chalk_ir::visit::Visitor

pub trait Visitor<'i, I: Interner> where
    I: 'i, 
{ type BreakTy; pub fn as_dyn(&mut self) -> &mut dyn Visitor<'i, I, BreakTy = Self::BreakTy>;
pub fn interner(&self) -> &'i I; pub fn visit_ty(
        &mut self,
        ty: &Ty<I>,
        outer_binder: DebruijnIndex
    ) -> ControlFlow<Self::BreakTy> { ... }
pub fn visit_lifetime(
        &mut self,
        lifetime: &Lifetime<I>,
        outer_binder: DebruijnIndex
    ) -> ControlFlow<Self::BreakTy> { ... }
pub fn visit_const(
        &mut self,
        constant: &Const<I>,
        outer_binder: DebruijnIndex
    ) -> ControlFlow<Self::BreakTy> { ... }
pub fn visit_program_clause(
        &mut self,
        clause: &ProgramClause<I>,
        outer_binder: DebruijnIndex
    ) -> ControlFlow<Self::BreakTy> { ... }
pub fn visit_goal(
        &mut self,
        goal: &Goal<I>,
        outer_binder: DebruijnIndex
    ) -> ControlFlow<Self::BreakTy> { ... }
pub fn visit_domain_goal(
        &mut self,
        domain_goal: &DomainGoal<I>,
        outer_binder: DebruijnIndex
    ) -> ControlFlow<Self::BreakTy> { ... }
pub fn forbid_free_vars(&self) -> bool { ... }
pub fn visit_free_var(
        &mut self,
        bound_var: BoundVar,
        outer_binder: DebruijnIndex
    ) -> ControlFlow<Self::BreakTy> { ... }
pub fn forbid_free_placeholders(&self) -> bool { ... }
pub fn visit_free_placeholder(
        &mut self,
        universe: PlaceholderIndex,
        _outer_binder: DebruijnIndex
    ) -> ControlFlow<Self::BreakTy> { ... }
pub fn visit_where_clause(
        &mut self,
        where_clause: &WhereClause<I>,
        outer_binder: DebruijnIndex
    ) -> ControlFlow<Self::BreakTy> { ... }
pub fn forbid_inference_vars(&self) -> bool { ... }
pub fn visit_inference_var(
        &mut self,
        var: InferenceVar,
        _outer_binder: DebruijnIndex
    ) -> ControlFlow<Self::BreakTy> { ... } }

A "visitor" recursively folds some term -- that is, some bit of IR, such as a Goal, and computes a value as a result.

To apply a visitor, use the Visit::visit_with method, like so

This example is not tested
let result = x.visit_with(&mut visitor, 0);

Associated Types

type BreakTy[src]

The "break type" of the visitor, often (). It represents the result the visitor yields when it stops visiting.

Loading content...

Required methods

pub fn as_dyn(&mut self) -> &mut dyn Visitor<'i, I, BreakTy = Self::BreakTy>[src]

Creates a dyn value from this visitor. Unfortunately, this must be added manually to each impl of visitor; it permits the default implements below to create a &mut dyn Visitor from Self without knowing what Self is (by invoking this method). Effectively, this limits impls of visitor to types for which we are able to create a dyn value (i.e., not [T] types).

pub fn interner(&self) -> &'i I[src]

Gets the visitor's interner.

Loading content...

Provided methods

pub fn visit_ty(
    &mut self,
    ty: &Ty<I>,
    outer_binder: DebruijnIndex
) -> ControlFlow<Self::BreakTy>
[src]

Top-level callback: invoked for each Ty<I> that is encountered when visiting. By default, invokes super_visit_with, which will in turn invoke the more specialized visiting methods below, like visit_free_var.

pub fn visit_lifetime(
    &mut self,
    lifetime: &Lifetime<I>,
    outer_binder: DebruijnIndex
) -> ControlFlow<Self::BreakTy>
[src]

Top-level callback: invoked for each Lifetime<I> that is encountered when visiting. By default, invokes super_visit_with, which will in turn invoke the more specialized visiting methods below, like visit_free_var.

pub fn visit_const(
    &mut self,
    constant: &Const<I>,
    outer_binder: DebruijnIndex
) -> ControlFlow<Self::BreakTy>
[src]

Top-level callback: invoked for each Const<I> that is encountered when visiting. By default, invokes super_visit_with, which will in turn invoke the more specialized visiting methods below, like visit_free_var.

pub fn visit_program_clause(
    &mut self,
    clause: &ProgramClause<I>,
    outer_binder: DebruijnIndex
) -> ControlFlow<Self::BreakTy>
[src]

Invoked for every program clause. By default, recursively visits the goals contents.

pub fn visit_goal(
    &mut self,
    goal: &Goal<I>,
    outer_binder: DebruijnIndex
) -> ControlFlow<Self::BreakTy>
[src]

Invoked for every goal. By default, recursively visits the goals contents.

pub fn visit_domain_goal(
    &mut self,
    domain_goal: &DomainGoal<I>,
    outer_binder: DebruijnIndex
) -> ControlFlow<Self::BreakTy>
[src]

Invoked for each domain goal.

pub fn forbid_free_vars(&self) -> bool[src]

If overridden to return true, then visiting will panic if a free variable is encountered. This should be done if free type/lifetime/const variables are not expected.

pub fn visit_free_var(
    &mut self,
    bound_var: BoundVar,
    outer_binder: DebruijnIndex
) -> ControlFlow<Self::BreakTy>
[src]

Invoked for BoundVar instances that are not bound within the type being visited over:

pub fn forbid_free_placeholders(&self) -> bool[src]

If overridden to return true, we will panic when a free placeholder type/lifetime is encountered.

pub fn visit_free_placeholder(
    &mut self,
    universe: PlaceholderIndex,
    _outer_binder: DebruijnIndex
) -> ControlFlow<Self::BreakTy>
[src]

Invoked for each occurrence of a placeholder type; these are used when we instantiate binders universally.

pub fn visit_where_clause(
    &mut self,
    where_clause: &WhereClause<I>,
    outer_binder: DebruijnIndex
) -> ControlFlow<Self::BreakTy>
[src]

Invoked for each where clause.

pub fn forbid_inference_vars(&self) -> bool[src]

If overridden to return true, inference variables will trigger panics when visited. Used when inference variables are unexpected.

pub fn visit_inference_var(
    &mut self,
    var: InferenceVar,
    _outer_binder: DebruijnIndex
) -> ControlFlow<Self::BreakTy>
[src]

Invoked for each occurrence of a inference type; these are used when we instantiate binders universally.

Loading content...

Implementors

Loading content...