@@ -28,7 +28,7 @@ use rustc_middle::ty::{
28
28
use rustc_middle:: { bug, span_bug} ;
29
29
use rustc_span:: { ErrorGuaranteed , Span } ;
30
30
use rustc_trait_selection:: infer:: InferCtxtExt ;
31
- use tracing:: { debug, trace} ;
31
+ use tracing:: { debug, instrument , trace} ;
32
32
33
33
use crate :: fn_ctxt:: FnCtxt ;
34
34
@@ -320,19 +320,17 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
320
320
Ok ( ( ) )
321
321
}
322
322
323
+ #[ instrument( skip( self ) , level = "debug" ) ]
323
324
fn consume_or_copy ( & self , place_with_id : & PlaceWithHirId < ' tcx > , diag_expr_id : HirId ) {
324
- debug ! ( "delegate_consume(place_with_id={:?})" , place_with_id) ;
325
-
326
325
if self . cx . type_is_copy_modulo_regions ( place_with_id. place . ty ( ) ) {
327
326
self . delegate . borrow_mut ( ) . copy ( place_with_id, diag_expr_id) ;
328
327
} else {
329
328
self . delegate . borrow_mut ( ) . consume ( place_with_id, diag_expr_id) ;
330
329
}
331
330
}
332
331
332
+ #[ instrument( skip( self ) , level = "debug" ) ]
333
333
pub fn consume_clone_or_copy ( & self , place_with_id : & PlaceWithHirId < ' tcx > , diag_expr_id : HirId ) {
334
- debug ! ( "delegate_consume_or_clone(place_with_id={:?})" , place_with_id) ;
335
-
336
334
// `x.use` will do one of the following
337
335
// * if it implements `Copy`, it will be a copy
338
336
// * if it implements `UseCloned`, it will be a call to `clone`
@@ -357,18 +355,16 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
357
355
}
358
356
359
357
// FIXME: It's suspicious that this is public; clippy should probably use `walk_expr`.
358
+ #[ instrument( skip( self ) , level = "debug" ) ]
360
359
pub fn consume_expr ( & self , expr : & hir:: Expr < ' _ > ) -> Result < ( ) , Cx :: Error > {
361
- debug ! ( "consume_expr(expr={:?})" , expr) ;
362
-
363
360
let place_with_id = self . cat_expr ( expr) ?;
364
361
self . consume_or_copy ( & place_with_id, place_with_id. hir_id ) ;
365
362
self . walk_expr ( expr) ?;
366
363
Ok ( ( ) )
367
364
}
368
365
366
+ #[ instrument( skip( self ) , level = "debug" ) ]
369
367
pub fn consume_or_clone_expr ( & self , expr : & hir:: Expr < ' _ > ) -> Result < ( ) , Cx :: Error > {
370
- debug ! ( "consume_or_clone_expr(expr={:?})" , expr) ;
371
-
372
368
let place_with_id = self . cat_expr ( expr) ?;
373
369
self . consume_clone_or_copy ( & place_with_id, place_with_id. hir_id ) ;
374
370
self . walk_expr ( expr) ?;
@@ -382,17 +378,15 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
382
378
Ok ( ( ) )
383
379
}
384
380
381
+ #[ instrument( skip( self ) , level = "debug" ) ]
385
382
fn borrow_expr ( & self , expr : & hir:: Expr < ' _ > , bk : ty:: BorrowKind ) -> Result < ( ) , Cx :: Error > {
386
- debug ! ( "borrow_expr(expr={:?}, bk={:?})" , expr, bk) ;
387
-
388
383
let place_with_id = self . cat_expr ( expr) ?;
389
384
self . delegate . borrow_mut ( ) . borrow ( & place_with_id, place_with_id. hir_id , bk) ;
390
385
self . walk_expr ( expr)
391
386
}
392
387
388
+ #[ instrument( skip( self ) , level = "debug" ) ]
393
389
pub fn walk_expr ( & self , expr : & hir:: Expr < ' _ > ) -> Result < ( ) , Cx :: Error > {
394
- debug ! ( "walk_expr(expr={:?})" , expr) ;
395
-
396
390
self . walk_adjustment ( expr) ?;
397
391
398
392
match expr. kind {
@@ -739,9 +733,8 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
739
733
740
734
/// Indicates that the value of `blk` will be consumed, meaning either copied or moved
741
735
/// depending on its type.
736
+ #[ instrument( skip( self ) , level = "debug" ) ]
742
737
fn walk_block ( & self , blk : & hir:: Block < ' _ > ) -> Result < ( ) , Cx :: Error > {
743
- debug ! ( "walk_block(blk.hir_id={})" , blk. hir_id) ;
744
-
745
738
for stmt in blk. stmts {
746
739
self . walk_stmt ( stmt) ?;
747
740
}
@@ -963,14 +956,13 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
963
956
///
964
957
/// Do note that discrepancies like these do still create weird language
965
958
/// semantics, and should be avoided if possible.
959
+ #[ instrument( skip( self ) , level = "debug" ) ]
966
960
fn walk_pat (
967
961
& self ,
968
962
discr_place : & PlaceWithHirId < ' tcx > ,
969
963
pat : & hir:: Pat < ' _ > ,
970
964
has_guard : bool ,
971
965
) -> Result < ( ) , Cx :: Error > {
972
- debug ! ( "walk_pat(discr_place={:?}, pat={:?}, has_guard={:?})" , discr_place, pat, has_guard) ;
973
-
974
966
let tcx = self . cx . tcx ( ) ;
975
967
self . cat_pattern ( discr_place. clone ( ) , pat, & mut |place, pat| {
976
968
debug ! ( "walk_pat: pat.kind={:?}" , pat. kind) ;
@@ -1121,6 +1113,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
1121
1113
///
1122
1114
/// - When reporting the Place back to the Delegate, ensure that the UpvarId uses the enclosing
1123
1115
/// closure as the DefId.
1116
+ #[ instrument( skip( self ) , level = "debug" ) ]
1124
1117
fn walk_captures ( & self , closure_expr : & hir:: Closure < ' _ > ) -> Result < ( ) , Cx :: Error > {
1125
1118
fn upvar_is_local_variable (
1126
1119
upvars : Option < & FxIndexMap < HirId , hir:: Upvar > > ,
@@ -1130,8 +1123,6 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
1130
1123
upvars. map ( |upvars| !upvars. contains_key ( & upvar_id) ) . unwrap_or ( body_owner_is_closure)
1131
1124
}
1132
1125
1133
- debug ! ( "walk_captures({:?})" , closure_expr) ;
1134
-
1135
1126
let tcx = self . cx . tcx ( ) ;
1136
1127
let closure_def_id = closure_expr. def_id ;
1137
1128
// For purposes of this function, coroutine and closures are equivalent.
0 commit comments