Skip to content

Commit 72eccf2

Browse files
Remove unncessary mut ref
1 parent d7595eb commit 72eccf2

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

Diff for: compiler/rustc_hir_typeck/src/expr_use_visitor.rs

+38-2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,42 @@ pub trait Delegate<'tcx> {
8686
);
8787
}
8888

89+
impl<'tcx, D: Delegate<'tcx>> Delegate<'tcx> for &mut D {
90+
fn consume(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
91+
(**self).consume(place_with_id, diag_expr_id)
92+
}
93+
94+
fn borrow(
95+
&mut self,
96+
place_with_id: &PlaceWithHirId<'tcx>,
97+
diag_expr_id: HirId,
98+
bk: ty::BorrowKind,
99+
) {
100+
(**self).borrow(place_with_id, diag_expr_id, bk)
101+
}
102+
103+
fn copy(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
104+
(**self).copy(place_with_id, diag_expr_id)
105+
}
106+
107+
fn mutate(&mut self, assignee_place: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
108+
(**self).mutate(assignee_place, diag_expr_id)
109+
}
110+
111+
fn bind(&mut self, binding_place: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
112+
(**self).bind(binding_place, diag_expr_id)
113+
}
114+
115+
fn fake_read(
116+
&mut self,
117+
place_with_id: &PlaceWithHirId<'tcx>,
118+
cause: FakeReadCause,
119+
diag_expr_id: HirId,
120+
) {
121+
(**self).fake_read(place_with_id, cause, diag_expr_id)
122+
}
123+
}
124+
89125
/// The ExprUseVisitor type
90126
///
91127
/// This is the code that actually walks the tree.
@@ -95,7 +131,7 @@ pub struct ExprUseVisitor<'a, 'tcx, D: Delegate<'tcx>> {
95131
param_env: ty::ParamEnv<'tcx>,
96132
upvars: Option<&'tcx FxIndexMap<HirId, hir::Upvar>>,
97133
body_owner: LocalDefId,
98-
delegate: RefCell<&'a mut D>,
134+
delegate: RefCell<D>,
99135
}
100136

101137
/// If the MC results in an error, it's because the type check
@@ -124,7 +160,7 @@ impl<'a, 'tcx, D: Delegate<'tcx>> ExprUseVisitor<'a, 'tcx, D> {
124160
/// - `param_env` --- parameter environment for trait lookups (esp. pertaining to `Copy`)
125161
/// - `typeck_results` --- typeck results for the code being analyzed
126162
pub fn new(
127-
delegate: &'a mut D,
163+
delegate: D,
128164
infcx: &'a InferCtxt<'tcx>,
129165
body_owner: LocalDefId,
130166
param_env: ty::ParamEnv<'tcx>,

0 commit comments

Comments
 (0)