pub trait Delegate<'tcx> {
// Required methods
fn consume(
&mut self,
place_with_id: &PlaceWithHirId<'tcx>,
diag_expr_id: HirId,
);
fn use_cloned(
&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§
Sourcefn consume(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: HirId)
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.
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.
Sourcefn use_cloned(
&mut self,
place_with_id: &PlaceWithHirId<'tcx>,
diag_expr_id: HirId,
)
fn use_cloned( &mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: HirId, )
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.
Sourcefn borrow(
&mut self,
place_with_id: &PlaceWithHirId<'tcx>,
diag_expr_id: HirId,
bk: BorrowKind,
)
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).
Sourcefn mutate(&mut self, assignee_place: &PlaceWithHirId<'tcx>, diag_expr_id: HirId)
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).
Sourcefn fake_read(
&mut self,
place_with_id: &PlaceWithHirId<'tcx>,
cause: FakeReadCause,
diag_expr_id: HirId,
)
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§
Sourcefn copy(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: HirId)
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).
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.
Sourcefn bind(&mut self, binding_place: &PlaceWithHirId<'tcx>, diag_expr_id: HirId)
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;