@@ -86,6 +86,42 @@ pub trait Delegate<'tcx> {
86
86
) ;
87
87
}
88
88
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
+
89
125
/// The ExprUseVisitor type
90
126
///
91
127
/// This is the code that actually walks the tree.
@@ -95,7 +131,7 @@ pub struct ExprUseVisitor<'a, 'tcx, D: Delegate<'tcx>> {
95
131
param_env : ty:: ParamEnv < ' tcx > ,
96
132
upvars : Option < & ' tcx FxIndexMap < HirId , hir:: Upvar > > ,
97
133
body_owner : LocalDefId ,
98
- delegate : RefCell < & ' a mut D > ,
134
+ delegate : RefCell < D > ,
99
135
}
100
136
101
137
/// 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> {
124
160
/// - `param_env` --- parameter environment for trait lookups (esp. pertaining to `Copy`)
125
161
/// - `typeck_results` --- typeck results for the code being analyzed
126
162
pub fn new (
127
- delegate : & ' a mut D ,
163
+ delegate : D ,
128
164
infcx : & ' a InferCtxt < ' tcx > ,
129
165
body_owner : LocalDefId ,
130
166
param_env : ty:: ParamEnv < ' tcx > ,
0 commit comments