Trait rustc_hir_typeck::expr_use_visitor::Delegate

source ·
pub trait Delegate<'tcx> {
    // Required methods
    fn consume(
        &mut self,
        place_with_id: &PlaceWithHirId<'tcx>,
        diag_expr_id: HirId
    );
    fn borrow(
        &mut self,
        place_with_id: &PlaceWithHirId<'tcx>,
        diag_expr_id: HirId,
        bk: BorrowKind
    );
    fn mutate(
        &mut self,
        assignee_place: &PlaceWithHirId<'tcx>,
        diag_expr_id: HirId
    );
    fn fake_read(
        &mut self,
        place_with_id: &PlaceWithHirId<'tcx>,
        cause: FakeReadCause,
        diag_expr_id: HirId
    );

    // Provided methods
    fn copy(
        &mut self,
        place_with_id: &PlaceWithHirId<'tcx>,
        diag_expr_id: HirId
    ) { ... }
    fn bind(
        &mut self,
        binding_place: &PlaceWithHirId<'tcx>,
        diag_expr_id: HirId
    ) { ... }
}
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: &PlaceWithHirId<'tcx>, diag_expr_id: HirId)

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

Use of a Copy type in a ByValue 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: &PlaceWithHirId<'tcx>, diag_expr_id: HirId, bk: BorrowKind )

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: &PlaceWithHirId<'tcx>, diag_expr_id: HirId)

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: &PlaceWithHirId<'tcx>, cause: FakeReadCause, diag_expr_id: HirId )

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

Provided Methods§

source

fn copy(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: HirId)

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

source

fn bind(&mut self, binding_place: &PlaceWithHirId<'tcx>, diag_expr_id: HirId)

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

This covers cases such as let x = 42;

Implementors§

source§

impl<'tcx> Delegate<'tcx> for InferBorrowKind<'tcx>