Remove is_autoref parameter
This commit is contained in:
parent
12d8ca113c
commit
2fcd542734
8 changed files with 12 additions and 22 deletions
|
|
@ -103,11 +103,10 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> {
|
|||
place_with_id: &expr_use_visitor::PlaceWithHirId<'tcx>,
|
||||
diag_expr_id: HirId,
|
||||
bk: rustc_middle::ty::BorrowKind,
|
||||
is_autoref: bool,
|
||||
) {
|
||||
debug!(
|
||||
"borrow: place_with_id = {place_with_id:?}, diag_expr_id={diag_expr_id:?}, \
|
||||
borrow_kind={bk:?}, is_autoref={is_autoref}"
|
||||
borrow_kind={bk:?}"
|
||||
);
|
||||
|
||||
self.places
|
||||
|
|
|
|||
|
|
@ -1792,7 +1792,6 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> {
|
|||
place_with_id: &PlaceWithHirId<'tcx>,
|
||||
diag_expr_id: hir::HirId,
|
||||
bk: ty::BorrowKind,
|
||||
_is_autoref: bool,
|
||||
) {
|
||||
let PlaceBase::Upvar(upvar_id) = place_with_id.place.base else { return };
|
||||
assert_eq!(self.closure_def_id, upvar_id.closure_expr_id);
|
||||
|
|
@ -1827,7 +1826,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> {
|
|||
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn mutate(&mut self, assignee_place: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId) {
|
||||
self.borrow(assignee_place, diag_expr_id, ty::BorrowKind::MutBorrow, false);
|
||||
self.borrow(assignee_place, diag_expr_id, ty::BorrowKind::MutBorrow);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ pub trait Delegate<'tcx> {
|
|||
place_with_id: &PlaceWithHirId<'tcx>,
|
||||
diag_expr_id: hir::HirId,
|
||||
bk: ty::BorrowKind,
|
||||
is_autoref: bool,
|
||||
);
|
||||
|
||||
/// The value found at `place` is being copied.
|
||||
|
|
@ -53,7 +52,7 @@ pub trait Delegate<'tcx> {
|
|||
fn copy(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId) {
|
||||
// In most cases, copying data from `x` is equivalent to doing `*&x`, so by default
|
||||
// we treat a copy of `x` as a borrow of `x`.
|
||||
self.borrow(place_with_id, diag_expr_id, ty::BorrowKind::ImmBorrow, false)
|
||||
self.borrow(place_with_id, diag_expr_id, ty::BorrowKind::ImmBorrow)
|
||||
}
|
||||
|
||||
/// The path at `assignee_place` is being assigned to.
|
||||
|
|
@ -184,7 +183,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
debug!("borrow_expr(expr={:?}, bk={:?})", expr, bk);
|
||||
|
||||
let place_with_id = return_if_err!(self.mc.cat_expr(expr));
|
||||
self.delegate.borrow(&place_with_id, place_with_id.hir_id, bk, false);
|
||||
self.delegate.borrow(&place_with_id, place_with_id.hir_id, bk);
|
||||
|
||||
self.walk_expr(expr)
|
||||
}
|
||||
|
|
@ -567,7 +566,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
// this is an autoref of `x`.
|
||||
adjustment::Adjust::Deref(Some(ref deref)) => {
|
||||
let bk = ty::BorrowKind::from_mutbl(deref.mutbl);
|
||||
self.delegate.borrow(&place_with_id, place_with_id.hir_id, bk, true);
|
||||
self.delegate.borrow(&place_with_id, place_with_id.hir_id, bk);
|
||||
}
|
||||
|
||||
adjustment::Adjust::Borrow(ref autoref) => {
|
||||
|
|
@ -599,19 +598,13 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
base_place,
|
||||
base_place.hir_id,
|
||||
ty::BorrowKind::from_mutbl(m.into()),
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
adjustment::AutoBorrow::RawPtr(m) => {
|
||||
debug!("walk_autoref: expr.hir_id={} base_place={:?}", expr.hir_id, base_place);
|
||||
|
||||
self.delegate.borrow(
|
||||
base_place,
|
||||
base_place.hir_id,
|
||||
ty::BorrowKind::from_mutbl(m),
|
||||
true,
|
||||
);
|
||||
self.delegate.borrow(base_place, base_place.hir_id, ty::BorrowKind::from_mutbl(m));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -684,7 +677,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
match bm {
|
||||
ty::BindByReference(m) => {
|
||||
let bk = ty::BorrowKind::from_mutbl(m);
|
||||
delegate.borrow(place, discr_place.hir_id, bk, false);
|
||||
delegate.borrow(place, discr_place.hir_id, bk);
|
||||
}
|
||||
ty::BindByValue(..) => {
|
||||
debug!("walk_pat binding consuming pat");
|
||||
|
|
@ -814,7 +807,6 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
&place_with_id,
|
||||
place_with_id.hir_id,
|
||||
upvar_borrow,
|
||||
false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind, _is_autoref: bool) {
|
||||
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind) {
|
||||
if cmt.place.projections.is_empty() {
|
||||
if let PlaceBase::Local(lid) = cmt.place.base {
|
||||
self.set.remove(&lid);
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ struct MutatePairDelegate<'a, 'tcx> {
|
|||
impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> {
|
||||
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
|
||||
|
||||
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, diag_expr_id: HirId, bk: ty::BorrowKind, _is_autoref: bool) {
|
||||
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, diag_expr_id: HirId, bk: ty::BorrowKind) {
|
||||
if bk == ty::BorrowKind::MutBorrow {
|
||||
if let PlaceBase::Local(id) = cmt.place.base {
|
||||
if Some(id) == self.hir_id_low && !BreakAfterExprVisitor::is_found(self.cx, diag_expr_id) {
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ impl<'tcx> euv::Delegate<'tcx> for MovedVariablesCtxt {
|
|||
self.move_common(cmt);
|
||||
}
|
||||
|
||||
fn borrow(&mut self, _: &euv::PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind, _is_autoref: bool) {}
|
||||
fn borrow(&mut self, _: &euv::PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind) {}
|
||||
|
||||
fn mutate(&mut self, _: &euv::PlaceWithHirId<'tcx>, _: HirId) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -886,7 +886,7 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
|
|||
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind, _is_autoref: bool) {
|
||||
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind) {
|
||||
if let PlaceBase::Local(id) = cmt.place.base {
|
||||
let map = self.cx.tcx.hir();
|
||||
let span = map.span(cmt.hir_id);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ impl<'tcx> MutVarsDelegate {
|
|||
impl<'tcx> Delegate<'tcx> for MutVarsDelegate {
|
||||
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
|
||||
|
||||
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, bk: ty::BorrowKind, _is_autoref: bool) {
|
||||
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, bk: ty::BorrowKind) {
|
||||
if bk == ty::BorrowKind::MutBorrow {
|
||||
self.update(cmt);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue