@@ -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
}
@@ -948,14 +941,13 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
948
941
}
949
942
950
943
/// The core driver for walking a pattern
944
+ #[ instrument( skip( self ) , level = "debug" ) ]
951
945
fn walk_pat (
952
946
& self ,
953
947
discr_place : & PlaceWithHirId < ' tcx > ,
954
948
pat : & hir:: Pat < ' _ > ,
955
949
has_guard : bool ,
956
950
) -> Result < ( ) , Cx :: Error > {
957
- debug ! ( "walk_pat(discr_place={:?}, pat={:?}, has_guard={:?})" , discr_place, pat, has_guard) ;
958
-
959
951
let tcx = self . cx . tcx ( ) ;
960
952
self . cat_pattern ( discr_place. clone ( ) , pat, & mut |place, pat| {
961
953
match pat. kind {
@@ -1048,6 +1040,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
1048
1040
///
1049
1041
/// - When reporting the Place back to the Delegate, ensure that the UpvarId uses the enclosing
1050
1042
/// closure as the DefId.
1043
+ #[ instrument( skip( self ) , level = "debug" ) ]
1051
1044
fn walk_captures ( & self , closure_expr : & hir:: Closure < ' _ > ) -> Result < ( ) , Cx :: Error > {
1052
1045
fn upvar_is_local_variable (
1053
1046
upvars : Option < & FxIndexMap < HirId , hir:: Upvar > > ,
@@ -1057,8 +1050,6 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
1057
1050
upvars. map ( |upvars| !upvars. contains_key ( & upvar_id) ) . unwrap_or ( body_owner_is_closure)
1058
1051
}
1059
1052
1060
- debug ! ( "walk_captures({:?})" , closure_expr) ;
1061
-
1062
1053
let tcx = self . cx . tcx ( ) ;
1063
1054
let closure_def_id = closure_expr. def_id ;
1064
1055
// For purposes of this function, coroutine and closures are equivalent.
0 commit comments