2
2
//! normal visitor, which just walks the entire body in one shot, the
3
3
//! `ExprUseVisitor` determines how expressions are being used.
4
4
5
+ #![ allow( unused_imports) ]
6
+
5
7
use std:: cell:: { Ref , RefCell } ;
6
8
use std:: ops:: Deref ;
7
9
use std:: slice:: from_ref;
@@ -29,8 +31,6 @@ use rustc_trait_selection::infer::InferCtxtExt;
29
31
use tracing:: { debug, trace} ;
30
32
use ty:: BorrowKind :: ImmBorrow ;
31
33
32
- use crate :: fn_ctxt:: FnCtxt ;
33
-
34
34
/// This trait defines the callbacks you can expect to receive when
35
35
/// employing the ExprUseVisitor.
36
36
pub trait Delegate < ' tcx > {
@@ -150,6 +150,7 @@ pub trait TypeInformationCtxt<'tcx> {
150
150
fn tcx ( & self ) -> TyCtxt < ' tcx > ;
151
151
}
152
152
153
+ /*
153
154
impl<'tcx> TypeInformationCtxt<'tcx> for &FnCtxt<'_, 'tcx> {
154
155
type TypeckResults<'a> = Ref<'a, ty::TypeckResults<'tcx>>
155
156
where
@@ -238,6 +239,51 @@ impl<'tcx> TypeInformationCtxt<'tcx> for (&LateContext<'tcx>, LocalDefId) {
238
239
self.0.tcx
239
240
}
240
241
}
242
+ */
243
+
244
+ impl < ' tcx > TypeInformationCtxt < ' tcx > for & crate :: upvar:: FnCtxt < ' _ , ' tcx > {
245
+ type TypeckResults < ' a > = & ' tcx ty:: TypeckResults < ' tcx >
246
+ where
247
+ Self : ' a ;
248
+
249
+ type Error = !;
250
+
251
+ fn typeck_results ( & self ) -> Self :: TypeckResults < ' _ > {
252
+ self . typeck_results
253
+ }
254
+
255
+ fn try_structurally_resolve_type ( & self , _span : Span , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
256
+ ty
257
+ }
258
+
259
+ fn resolve_vars_if_possible < T : TypeFoldable < TyCtxt < ' tcx > > > ( & self , t : T ) -> T {
260
+ t
261
+ }
262
+
263
+ fn report_error ( & self , span : Span , msg : impl ToString ) -> ! {
264
+ span_bug ! ( span, "{}" , msg. to_string( ) )
265
+ }
266
+
267
+ fn error_reported_in_ty ( & self , _ty : Ty < ' tcx > ) -> Result < ( ) , !> {
268
+ Ok ( ( ) )
269
+ }
270
+
271
+ fn tainted_by_errors ( & self ) -> Result < ( ) , !> {
272
+ Ok ( ( ) )
273
+ }
274
+
275
+ fn type_is_copy_modulo_regions ( & self , ty : Ty < ' tcx > ) -> bool {
276
+ ty. is_copy_modulo_regions ( self . tcx , self . param_env )
277
+ }
278
+
279
+ fn body_owner_def_id ( & self ) -> LocalDefId {
280
+ self . closure_def_id
281
+ }
282
+
283
+ fn tcx ( & self ) -> TyCtxt < ' tcx > {
284
+ self . tcx
285
+ }
286
+ }
241
287
242
288
/// The ExprUseVisitor type
243
289
///
@@ -250,11 +296,13 @@ pub struct ExprUseVisitor<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>
250
296
upvars : Option < & ' tcx FxIndexMap < HirId , hir:: Upvar > > ,
251
297
}
252
298
299
+ /*
253
300
impl<'a, 'tcx, D: Delegate<'tcx>> ExprUseVisitor<'tcx, (&'a LateContext<'tcx>, LocalDefId), D> {
254
301
pub fn for_clippy(cx: &'a LateContext<'tcx>, body_def_id: LocalDefId, delegate: D) -> Self {
255
302
Self::new((cx, body_def_id), delegate)
256
303
}
257
304
}
305
+ */
258
306
259
307
impl < ' tcx , Cx : TypeInformationCtxt < ' tcx > , D : Delegate < ' tcx > > ExprUseVisitor < ' tcx , Cx , D > {
260
308
/// Creates the ExprUseVisitor, configuring it with the various options provided:
0 commit comments