Skip to main content

Delegate

Trait Delegate 

Source
pub(crate) trait Delegate<'db> {
    // Required methods
    fn consume(
        &mut self,
        place_with_id: PlaceWithOrigin,
        ctx: &mut InferenceContext<'db>,
    );
    fn use_cloned(
        &mut self,
        place_with_id: PlaceWithOrigin,
        ctx: &mut InferenceContext<'db>,
    );
    fn borrow(
        &mut self,
        place_with_id: PlaceWithOrigin,
        bk: BorrowKind,
        ctx: &mut InferenceContext<'db>,
    );
    fn mutate(
        &mut self,
        assignee_place: PlaceWithOrigin,
        ctx: &mut InferenceContext<'db>,
    );
    fn fake_read(
        &mut self,
        place_with_id: PlaceWithOrigin,
        cause: FakeReadCause,
        ctx: &mut InferenceContext<'db>,
    );

    // Provided methods
    fn copy(
        &mut self,
        place_with_id: PlaceWithOrigin,
        ctx: &mut InferenceContext<'db>,
    ) { ... }
    fn bind(
        &mut self,
        binding_place: PlaceWithOrigin,
        ctx: &mut InferenceContext<'db>,
    ) { ... }
}
Expand description

This trait defines the callbacks you can expect to receive when employing the ExprUseVisitor.

Required Methods§

Source

fn consume( &mut self, place_with_id: PlaceWithOrigin, ctx: &mut InferenceContext<'db>, )

The value found at place is moved, depending on mode. Where diag_expr_id is the id used for diagnostics for place.

If the value is Copy, copy is called instead, which by default falls back to borrow.

The parameter diag_expr_id indicates the HIR id that ought to be used for diagnostics. Around pattern matching such as let pat = expr, the diagnostic id will be the id of the expression expr but the place itself will have the id of the binding in the pattern pat.

Source

fn use_cloned( &mut self, place_with_id: PlaceWithOrigin, ctx: &mut InferenceContext<'db>, )

The value found at place is used, depending on mode. Where diag_expr_id is the id used for diagnostics for place.

Use of a Copy type in a ByUse context is considered a use by ImmBorrow and borrow is called instead. This is because a shared borrow is the “minimum access” that would be needed to perform a copy.

The parameter diag_expr_id indicates the HIR id that ought to be used for diagnostics. Around pattern matching such as let pat = expr, the diagnostic id will be the id of the expression expr but the place itself will have the id of the binding in the pattern pat.

Source

fn borrow( &mut self, place_with_id: PlaceWithOrigin, bk: BorrowKind, ctx: &mut InferenceContext<'db>, )

The value found at place is being borrowed with kind bk. diag_expr_id is the id used for diagnostics (see consume for more details).

Source

fn mutate( &mut self, assignee_place: PlaceWithOrigin, ctx: &mut InferenceContext<'db>, )

The path at assignee_place is being assigned to. diag_expr_id is the id used for diagnostics (see consume for more details).

Source

fn fake_read( &mut self, place_with_id: PlaceWithOrigin, cause: FakeReadCause, ctx: &mut InferenceContext<'db>, )

The place should be a fake read because of specified cause.

Provided Methods§

Source

fn copy( &mut self, place_with_id: PlaceWithOrigin, ctx: &mut InferenceContext<'db>, )

The value found at place is being copied. diag_expr_id is the id used for diagnostics (see consume for more details).

If an implementation is not provided, use of a Copy type in a ByValue context is instead considered a use by ImmBorrow and borrow is called instead. This is because a shared borrow is the “minimum access” that would be needed to perform a copy.

Source

fn bind( &mut self, binding_place: PlaceWithOrigin, ctx: &mut InferenceContext<'db>, )

The path at binding_place is a binding that is being initialized.

This covers cases such as let x = 42;

Implementations on Foreign Types§

Source§

impl<'db, D: Delegate<'db>> Delegate<'db> for &mut D

Source§

fn consume( &mut self, place_with_id: PlaceWithOrigin, ctx: &mut InferenceContext<'db>, )

Source§

fn use_cloned( &mut self, place_with_id: PlaceWithOrigin, ctx: &mut InferenceContext<'db>, )

Source§

fn borrow( &mut self, place_with_id: PlaceWithOrigin, bk: BorrowKind, ctx: &mut InferenceContext<'db>, )

Source§

fn copy( &mut self, place_with_id: PlaceWithOrigin, ctx: &mut InferenceContext<'db>, )

Source§

fn mutate( &mut self, assignee_place: PlaceWithOrigin, ctx: &mut InferenceContext<'db>, )

Source§

fn bind( &mut self, binding_place: PlaceWithOrigin, ctx: &mut InferenceContext<'db>, )

Source§

fn fake_read( &mut self, place_with_id: PlaceWithOrigin, cause: FakeReadCause, ctx: &mut InferenceContext<'db>, )

Implementors§